Browse Source

fixed bug

woso_javan 2 months ago
parent
commit
83cded87b3

+ 1 - 2
assets/module_storm_sunder/Prefabs/UI/Gambit/UI_BattleGambit_Impl.ts

@@ -24,15 +24,14 @@ export class UI_BattleGambit_Impl extends UI_BattleRevive {
         let layout = this.layout as Layout_BattleGambit;
         this.onButtonEvent(layout.btn_get, () => {
             this.changeGameStatus(GameStatus.Playing);
-            // EventDispatcher.instance.emit(GameEvent.EVENT_GAME_START_EFFECT);
             TimerMgr.inst.startCountdown();
+            EventDispatcher.instance.emit(GameEvent.EVENT_GAME_START_EFFECT);
         });
         this.onButtonEvent(layout.btn_back, () => {
             GameMgr.inst.isWin = false;
             GameMgr.inst.setGameStatus(GameStatus.Playing);
             TimerMgr.inst.startCountdown();
             EventDispatcher.instance.emit(GameEvent.EVENT_GAME_START);
-            console.log('开局点击No++++++++++')
             this.hide();
         });
     }

+ 1 - 1
assets/module_storm_sunder/Script/Component/TornadoAIComponent.ts

@@ -80,7 +80,7 @@ export class TornadoAIComponent extends TornadoComponent {
 
     /** 选择 AI 行为 */
     private decideAction() {
-        if (this.playerStatus == PlayerStatus.DIE) return; // AI 死亡时不执行行为
+        if (this.playerStatus == PlayerStatus.DIE || !this.node) return; // AI 死亡时不执行行为
 
         const move = Math.random() * 100 < this.moveProbability;
 

+ 5 - 11
assets/module_storm_sunder/Script/Manager/PlayerMgr.ts

@@ -221,9 +221,11 @@ export class PlayerMgr {
     //销毁除第一个节点外的其他AI节点
     public destroyOtherAI() {
         const playersUI = StormSunderGlobalInstance.instance.players!;
-        for (let i = 1; i < playersUI.removeChild.length; i++) {
-            playersUI.removeChild[i].destroy();
-        }
+        playersUI.children.forEach((child, index) => {
+            if (child.getComponent(TornadoAIComponent)) {
+                child.getComponent(TornadoAIComponent)!.node.destroy();
+            }
+        })
     }
 
     //随机拼接名称
@@ -252,14 +254,6 @@ export class PlayerMgr {
     reset() {
         this.destroyOtherAI();
         this.aiIndex = 0;
-
-        //去除掉除第一个节点外的其他AI节点
-        const playersUI = StormSunderGlobalInstance.instance.players!;
-        playersUI.children.forEach((child, index) => {
-            if (child.getComponent(TornadoAIComponent)) {
-                child.getComponent(TornadoAIComponent)!.node.destroy();
-            }
-        })
     }
 
 }

+ 1 - 2
assets/module_storm_sunder/Script/Manager/TimerMgr.ts

@@ -41,7 +41,6 @@ export class TimerMgr {
             this.upateLbTime();
         }, 1000); // 每秒减少一次
 
-        Scheduler.enableForTarget(this);
         director.getScheduler().schedule(this.update, this, 0);
     }
 
@@ -73,7 +72,7 @@ export class TimerMgr {
     // 销毁时清理
     public reset(): void {
         this.stopCountdown();
-        Scheduler.enableForTarget(this);
+        director.getScheduler().unscheduleAllForTarget(this);
 
         const mapConfig = MapMgr.Instance.getMapConfig(1);
         this.countDownTime = mapConfig.time;