|
@@ -25,6 +25,7 @@ export class TornadoComponent extends Component {
|
|
|
tigger: Collider = null!; //龙卷风触发器
|
|
|
radiusTigger: Collider = null!; //龙卷风半径检测触发器
|
|
|
|
|
|
+ ai: boolean = false;
|
|
|
attack: number = 20;
|
|
|
speed: number = 50;
|
|
|
currentExp: number = 0;
|
|
@@ -34,15 +35,8 @@ export class TornadoComponent extends Component {
|
|
|
playerStatus: PlayerStatus = PlayerStatus.LIFE;
|
|
|
playerInfo: PlayerInfo = null;
|
|
|
isColliding: boolean = false;
|
|
|
- //当前攻击的道具
|
|
|
- currentAttackProp: Node = null;
|
|
|
- private _ai: boolean = false;
|
|
|
- public get ai(): boolean {
|
|
|
- return this._ai;
|
|
|
- }
|
|
|
- public set ai(value: boolean) {
|
|
|
- this._ai = value;
|
|
|
- }
|
|
|
+ //当前攻击的道具或玩家
|
|
|
+ curHitObj: Node = null;
|
|
|
|
|
|
_attackInterval: number = 0.5; // 攻击间隔
|
|
|
_lastAttackTime: Map<string, number> = new Map(); // 记录上次攻击时间
|
|
@@ -91,6 +85,8 @@ export class TornadoComponent extends Component {
|
|
|
}
|
|
|
|
|
|
protected onTriggerEnter(event: ITriggerEvent): void {
|
|
|
+ if (GameMgr.inst.gameStatus !== GameStatus.Playing) return;
|
|
|
+
|
|
|
let _originalPosition = this.node.position.clone();
|
|
|
if (event.otherCollider.getGroup() === 1 << 2) {
|
|
|
if (this.isColliding) return; // 防止重复触发
|
|
@@ -128,12 +124,15 @@ export class TornadoComponent extends Component {
|
|
|
}
|
|
|
|
|
|
protected onTriggerStay(event: ITriggerEvent): void {
|
|
|
- if (event.otherCollider.getGroup() == 1 << 4) {
|
|
|
- const otherCollider = event.otherCollider;
|
|
|
- this.currentAttackProp = otherCollider.node;
|
|
|
+ if (GameMgr.inst.gameStatus !== GameStatus.Playing) return;
|
|
|
+
|
|
|
+ const otherCollider = event.otherCollider;
|
|
|
+
|
|
|
+ if (otherCollider.getGroup() == 1 << 4) {
|
|
|
+ this.curHitObj = otherCollider.node;
|
|
|
|
|
|
- if (!this.currentAttackProp.getComponent(PropComponent)) return;
|
|
|
- const propComponent = this.currentAttackProp.getComponent(PropComponent);
|
|
|
+ if (!this.curHitObj.getComponent(PropComponent)) return;
|
|
|
+ const propComponent = this.curHitObj.getComponent(PropComponent);
|
|
|
|
|
|
const currentTime = game.totalTime;
|
|
|
const nodeId = otherCollider.node.uuid;
|
|
@@ -155,16 +154,34 @@ export class TornadoComponent extends Component {
|
|
|
otherCollider.node.parent = randomPoint;
|
|
|
otherCollider.node.setPosition(Vec3.ZERO);
|
|
|
propComponent.swallow();
|
|
|
- this.addExpByProp();
|
|
|
+ this.addExpByKill();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ } else if (otherCollider.getGroup() == 1 << 3) {
|
|
|
+ const targetTornado = otherCollider.node.parent.getComponent(TornadoComponent);
|
|
|
+ if (!targetTornado) return;
|
|
|
+
|
|
|
+ if (this.currentLv > targetTornado.currentLv) {
|
|
|
+ console.log('撒日朗++++++++');
|
|
|
+ this.curHitObj = targetTornado.node;
|
|
|
+ this.addExpByKill();
|
|
|
+ this.killed(targetTornado.node);
|
|
|
+
|
|
|
+ targetTornado.node.removeFromParent();
|
|
|
+ targetTornado.node.destroy();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //被击杀
|
|
|
+ killed(targetNode: Node) {
|
|
|
+ Effect2DUIMgr.inst.removePlayerInfo(targetNode);
|
|
|
+ }
|
|
|
+
|
|
|
onTriggerExit(event: ITriggerEvent) {
|
|
|
if (event.otherCollider.getGroup() == 1 << 4) {
|
|
|
- this.currentAttackProp = null;
|
|
|
+ this.curHitObj = null;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -194,12 +211,19 @@ export class TornadoComponent extends Component {
|
|
|
this.node.setPosition(this.node.position.x + playerX, 0, this.node.position.z - playerZ);
|
|
|
}
|
|
|
|
|
|
- protected addExpByProp() {
|
|
|
- if (!this.currentAttackProp) return;
|
|
|
+ protected addExpByKill() {
|
|
|
+ if (!this.curHitObj) return;
|
|
|
+
|
|
|
+ const propComp = this.curHitObj.getComponent(PropComponent);
|
|
|
+ let objExp = 0;
|
|
|
+ if (this.curHitObj.getComponent(PropComponent)) {
|
|
|
+ objExp = propComp.currentExp;
|
|
|
+ } else {
|
|
|
+ //TODO 计算经验
|
|
|
+ objExp = this.currentLv * 10;
|
|
|
+ }
|
|
|
|
|
|
- const propComp = this.currentAttackProp.getComponent(PropComponent);
|
|
|
- const propExp = propComp.exp;
|
|
|
- this.currentExp += propExp;
|
|
|
+ this.currentExp += objExp;
|
|
|
if (this.currentExp >= this.nextExp) {
|
|
|
this.stormLevelUp();
|
|
|
this.currentLv++;
|