소스 검색

修改碰撞方式

woso_javan 2 달 전
부모
커밋
33ccd248ed
2개의 변경된 파일47개의 추가작업 그리고 14개의 파일을 삭제
  1. 26 12
      assets/module_storm_sunder/Script/Component/TornadoAIComponent.ts
  2. 21 2
      assets/module_storm_sunder/Script/Component/TornadoComponent.ts

+ 26 - 12
assets/module_storm_sunder/Script/Component/TornadoAIComponent.ts

@@ -76,7 +76,7 @@ export class TornadoAIComponent extends TornadoComponent {
         this.attack = this.attributeBonusMgr.getStormSunderAttack(this.currentLv, true);
         this.speed = this.attributeBonusMgr.getStormSunderSpeed(this.currentLv, true);
         this.speed = Math.round((this.speed / 2) * 100) / 100;
-        this.speed = this.speed * 1.2;//测试
+        // this.speed = this.speed * 1.2;//测试
         // console.log(`移动时长:${this.moveDuration} 逃离时长:${this.escapeDuration} 追击时长:${this.chaseDuration} 追击AI概率:${this.chaseAIProbability} 追击玩家概率:${this.chasePlayerProbability} 移动概率:${this.moveProbability}`);
     }
 
@@ -125,7 +125,7 @@ export class TornadoAIComponent extends TornadoComponent {
         }, this.moveDuration);
     }
 
-    protected override onTriggerEnter(event: ITriggerEvent): void {
+    protected onTriggerEnter(event: ITriggerEvent): void {
         if (event.otherCollider.getGroup() === 1 << 2) {
             this.unscheduleAllCallbacks();
             this.isChasing = false;
@@ -136,9 +136,33 @@ export class TornadoAIComponent extends TornadoComponent {
             this.setPositionByObstacle(event, () => {
                 this.decideAction();
             });
+        } else if (event.otherCollider.getGroup() === 1 << 3) {
+            if (event.otherCollider.node.name == 'radiusTigger') return;
+
+            const otherCollider = event.otherCollider;
+            const targetTornado = otherCollider.node.parent.getComponent(TornadoComponent);
+            if (!targetTornado) return;
+
+            if (event.selfCollider.node.name == 'RigibodyStorm') {
+                if (event.otherCollider.node.name == 'RigibodyStorm') {
+                    const isAI = targetTornado.ai;
+                    if (this.currentLv > targetTornado.currentLv) {
+                        if (!isAI) {
+                            GameMgr.inst.isWin = false;
+                            GameMgr.inst.setGameStatus(GameStatus.Revive);
+                        } else {
+                            this.onKilledHandler(targetTornado);
+                        }
+                    }
+                }
+            }
         }
     }
 
+    protected onKilledHandler(targetTornado: TornadoComponent): void {
+        super.onKilledHandler(targetTornado);
+    }
+
     protected onTriggerStay(event: ITriggerEvent): void {
         if (GameMgr.inst.getGameStatus() != GameStatus.Playing) return;
         super.onTriggerStay(event);
@@ -148,16 +172,6 @@ export class TornadoAIComponent extends TornadoComponent {
             const targetTornado = otherCollider.node.parent.getComponent(TornadoComponent);
             if (!targetTornado) return;
 
-            // const distance = Vec3.distance(this.node.worldPosition, otherCollider.node.worldPosition);
-            // if (distance < 0.2) {
-            //     const isAI = targetTornado.ai;
-            //     if (this.currentLv > targetTornado.currentLv && !isAI) {
-            //         GameMgr.inst.isWin = false;
-            //         // console.log(`AI 触发碰撞到:${targetTornado.name} isAI:${isAI}`);
-            //         GameMgr.inst.setGameStatus(GameStatus.Revive);
-            //     }
-            // }
-
             if (event.selfCollider.node.name == 'RigibodyStorm') {
                 if (event.otherCollider.node.name == 'RigibodyStorm') {
                     const distance = Vec3.distance(event.selfCollider.node.worldPosition, otherCollider.node.worldPosition);

+ 21 - 2
assets/module_storm_sunder/Script/Component/TornadoComponent.ts

@@ -97,7 +97,7 @@ export class TornadoComponent extends Component {
         this.nickName = userModel.nickName;
         this.height = userModel.game_tornado_base_height;
         this.speed = Math.round((this.speed / 2) * 100) / 100;
-        this.speed = this.speed * 1.8;//测试
+        // this.speed = this.speed * 1.8;//测试
 
         // console.log(`玩家的速度:${this.speed}`);
         this.playerInfo = {
@@ -120,9 +120,28 @@ export class TornadoComponent extends Component {
 
         if (event.otherCollider.getGroup() === 1 << 2) {
             this.setPositionByObstacle(event);
+        } else if (event.otherCollider.getGroup() === 1 << 3) {
+            const targetTornado = otherCollider.node.parent.getComponent(TornadoComponent);
+            if (!targetTornado) return;
+
+            if (event.selfCollider.node.name == 'RigibodyStorm') {
+                if (event.otherCollider.node.name == 'RigibodyStorm') {
+                    if (this.currentLv > targetTornado.currentLv) {
+                        this.onKilledHandler(targetTornado);
+                    }
+                }
+            }
         }
     }
 
+    protected onKilledHandler(targetTornado: TornadoComponent) {
+        StormSunderAudioMgr.playOneShot(StormSunderAudioMgr.getMusicIdName(5), 1.0);
+        this.curHitObj = targetTornado.node;
+        this.addExpByKill();
+        this.killed(targetTornado.node);
+        Effect2DUIMgr.inst.addPKInfo(this.nickName, targetTornado.nickName);
+    }
+
     protected setPositionByObstacle(event: ITriggerEvent, cb?: Function) {
         // console.log('离开碰撞物 isColliding:', this.isColliding);
         if (this.isColliding) return; // 防止重复触发
@@ -329,7 +348,7 @@ export class TornadoComponent extends Component {
         this.attack = attributeBonusMgr.getStormSunderAttack(this.currentLv);
         this.speed = attributeBonusMgr.getStormSunderSpeed(this.currentLv);
         this.speed = Math.round((this.speed / 2) * 100) / 100;
-        this.speed = this.speed * 1.8;//测试
+        // this.speed = this.speed * 1.8;//测试
         this.currentExp = 0;
 
         Effect2DUIMgr.inst.addLevelUp(this.node);