Forráskód Böngészése

fixed bug 追击击杀

woso_javan 2 hónapja
szülő
commit
9fc633bc0e

+ 3 - 3
assets/module_storm_sunder/Prefabs/Storm.prefab

@@ -3213,7 +3213,7 @@
       "__type__": "cc.Vec3",
       "x": 0,
       "y": 0,
-      "z": -2.593994281596679e-7
+      "z": 0
     },
     "_lrot": {
       "__type__": "cc.Quat",
@@ -3295,8 +3295,8 @@
       "y": 0,
       "z": 0
     },
-    "_radius": 5,
-    "_height": 2,
+    "_radius": 15,
+    "_height": 5,
     "_direction": 1,
     "_id": ""
   },

+ 0 - 1
assets/module_storm_sunder/Prefabs/UI/Revive/UI_BattleRevive_Impl.ts

@@ -21,7 +21,6 @@ export class UI_BattleRevive_Impl extends UI_BattleRevive {
         let layout = this.layout as Layout_BattleRevive;
         this.onButtonEvent(layout.btn_revive, () => {
             this.changeGameStatus(GameStatus.Playing);
-            this.hide();
         });
         this.onButtonEvent(layout.btn_back, () => {
             // this.changeGameStatus(GameStatus.None);

+ 33 - 23
assets/module_storm_sunder/Script/Component/TornadoAIComponent.ts

@@ -1,4 +1,4 @@
-import { BoxCollider, Component, ITriggerEvent, Node, Tween, Vec3, _decorator, randomRange } from 'cc';
+import { BoxCollider, Component, Game, ITriggerEvent, Node, Tween, Vec3, _decorator, randomRange } from 'cc';
 import { PathfindingManager } from '../Manager/PathfindingManager';
 import { PlayerStatus, TornadoComponent } from './TornadoComponent';
 import { GameUtil } from '../GameUtil';
@@ -119,8 +119,8 @@ export class TornadoAIComponent extends TornadoComponent {
         }, this.moveDuration);
     }
 
-    protected onTriggerEnter(event: ITriggerEvent): void {
-        const otherCollider = event.otherCollider;
+    protected override onTriggerEnter(event: ITriggerEvent): void {
+
         if (event.otherCollider.getGroup() === 1 << 2) {
             this.unscheduleAllCallbacks();
             this.isChasing = false;
@@ -131,24 +131,30 @@ export class TornadoAIComponent extends TornadoComponent {
             this.setPositionByObstacle(event, () => {
                 this.decideAction();
             });
-        } else if (event.otherCollider.getGroup() === 1 << 3) {
-            if (otherCollider.getGroup() == 1 << 3) {
-                const targetTornado = otherCollider.node.parent.getComponent(TornadoComponent);
-                if (!targetTornado) return;
+        }
+    }
+
+    protected onTriggerStay(event: ITriggerEvent): void {
+        if (GameMgr.inst.getGameStatus() != GameStatus.Playing) return;
+        super.onTriggerStay(event);
 
-                const isPlayer = targetTornado instanceof TornadoComponent;
-                if (this.currentLv > targetTornado.currentLv && isPlayer) {
+        const otherCollider = event.otherCollider;
+        if (event.otherCollider.getGroup() === 1 << 3) {
+            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);
                 }
             }
         }
     }
 
-    protected onTriggerStay(event: ITriggerEvent): void {
-        super.onTriggerStay(event);
-    }
-
     protected addExpByKill() {
         super.addExpByKill(true);
         // console.log(`AI 当前经验:${this.currentExp}`);
@@ -156,7 +162,6 @@ export class TornadoAIComponent extends TornadoComponent {
 
     /** 触发器检测(过程中遇到其他龙卷风) */
     protected onRadiusTriggerEnter(event: ITriggerEvent): void {
-        if (this.isChasing) return;
         const otherCollider = event.otherCollider;
         const otherNode = otherCollider.node;
 
@@ -173,6 +178,7 @@ export class TornadoAIComponent extends TornadoComponent {
             } else if (targetLv < this.currentLv) {
                 // 目标等级比自己低 → 先判断是否追击
                 if (Math.random() * 100 < this.chaseAIProbability) {
+                    this.cancelAction();
                     if (isTargetAI) {
                         // 目标是 AI,直接追击
                         this.chaseTarget(targetTornado.node);
@@ -204,24 +210,20 @@ export class TornadoAIComponent extends TornadoComponent {
     /** 追击目标 */
     private chaseTarget(target: Node) {
         if (this.isChasing) return;
-        // console.log(`AI 追击目标->>>>>>>>>>>>>`);
+        console.log(`AI 追击目标-> ${target.name}}`);
 
         this.isChasing = true;
         this.targetNode = target;
 
         PathfindingManager.getInstance().followTarget(this, target, this.speed, () => {
             // console.log(`AI 追击目标到达`);
-            this.unscheduleAllCallbacks();
-            this.isChasing = false;
-            this.targetNode = null;
+            this.cancelAction();
             this.decideAction();
         });
 
         // 追击时间结束后恢复行为
         this.scheduleOnce(() => {
-            this.isChasing = false;
-            this.targetNode = null;
-            this.decideAction();
+            this.cancelAction();
         }, this.chaseDuration);
     }
 
@@ -241,9 +243,17 @@ export class TornadoAIComponent extends TornadoComponent {
         PathfindingManager.getInstance().moveTo(this.node, escapePosition, this.escapeDuration);
 
         this.scheduleOnce(() => {
-            this.isEscaping = false;
-            this.decideAction();
+            this.cancelAction();
         }, this.escapeDuration);
     }
 
+    //取消AI行为
+    private cancelAction() {
+        this.unscheduleAllCallbacks();
+        this.isChasing = false;
+        this.isEscaping = false;
+        this.targetNode = null;
+        Tween.stopAllByTarget(this.node);
+    }
+
 }

+ 16 - 12
assets/module_storm_sunder/Script/Component/TornadoComponent.ts

@@ -100,18 +100,6 @@ export class TornadoComponent extends Component {
 
         if (event.otherCollider.getGroup() === 1 << 2) {
             this.setPositionByObstacle(event);
-        } else if (otherCollider.getGroup() == 1 << 3) {
-            const targetTornado = otherCollider.node.parent.getComponent(TornadoComponent);
-            if (!targetTornado) return;
-
-            if (this.currentLv > targetTornado.currentLv) {
-                StormSunderAudioMgr.playOneShot(StormSunderAudioMgr.getMusicIdName(5), 1.0);
-                this.curHitObj = targetTornado.node;
-                this.addExpByKill();
-                this.killed(targetTornado.node);
-
-                Effect2DUIMgr.inst.addPKInfo(this.nickName, targetTornado.nickName);
-            }
         }
     }
 
@@ -206,6 +194,22 @@ export class TornadoComponent extends Component {
                     this.addExpByKill();
                 }
             }
+        } else if (otherCollider.getGroup() == 1 << 3) {
+            const targetTornado = otherCollider.node.parent.getComponent(TornadoComponent);
+            if (!targetTornado) return;
+
+            const distance = Vec3.distance(event.selfCollider.node.worldPosition, otherCollider.node.worldPosition);
+            if (distance < 1) {
+                if (this.currentLv > targetTornado.currentLv) {
+                    // console.log(`玩家等级:${this.currentLv}  大于  targetTornado等级:${targetTornado.currentLv}`);
+                    StormSunderAudioMgr.playOneShot(StormSunderAudioMgr.getMusicIdName(5), 1.0);
+                    this.curHitObj = targetTornado.node;
+                    this.addExpByKill();
+                    this.killed(targetTornado.node);
+
+                    Effect2DUIMgr.inst.addPKInfo(this.nickName, targetTornado.nickName);
+                }
+            }
         }
 
     }

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 246 - 132
assets/module_storm_sunder/rooster_stormsunder.scene


Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott