woso_javan 2 ay önce
ebeveyn
işleme
b38f75a194

+ 18 - 2
assets/module_storm_sunder/Prefabs/UI/Match/UI_BattleMatch_Impl.ts

@@ -4,6 +4,10 @@ import { UI_BattleMatch, UI_BattleRevive } from "../../../../scripts/UIDef";
 import { GameMgr, GameStatus } from '../../../Script/Manager/GameMgr';
 import { tgxModuleContext } from 'db://assets/core_tgx/tgx';
 import { Layout_BattleMatch } from './Layout_BattleMatch';
+import { MapMgr } from '../../../Script/Manager/MapMgr';
+import { EventDispatcher } from 'db://assets/core_tgx/easy_ui_framework/EventDispatcher';
+import { GameEvent } from '../../../Script/Enum/GameEvent';
+import { GameUtil } from '../../../Script/GameUtil';
 const { ccclass, property } = _decorator;
 
 @ccclass('UI_BattleMatch_Impl')
@@ -21,11 +25,17 @@ export class UI_BattleMatch_Impl extends UI_BattleRevive {
     }
 
     protected onCreated(): void {
+        this.registerEvent();
         let layout = this.layout as Layout_BattleMatch;
         let match = layout.btn_match.node.getChildByName('Label').getComponent(Label);
         this.matchText = match;
         this.matchText.string = this.baseText;
         this.startTextAnimation();
+        MapMgr.Instance.addMapNode();
+    }
+
+    private registerEvent() {
+        EventDispatcher.instance.on(GameEvent.EVENT_MAP_LOAD_COMPLETE, this.onAnimationComplete, this);
     }
 
     startTextAnimation() {
@@ -60,7 +70,7 @@ export class UI_BattleMatch_Impl extends UI_BattleRevive {
             )
             .call(() => {
                 // 1秒后执行完成回调
-                this.onAnimationComplete();
+                // this.onAnimationComplete();
             })
             .union() // 合并前面的sequence
             .repeatForever() // 循环播放
@@ -74,11 +84,17 @@ export class UI_BattleMatch_Impl extends UI_BattleRevive {
         }
     }
 
-    private onAnimationComplete() {
+    private async onAnimationComplete() {
+        await GameUtil.delay(1);
+        this.unregisterEvent();
         this.stopAnimation();
         this.hide();
         GameMgr.inst.startGame();
     }
+
+    private unregisterEvent() {
+        EventDispatcher.instance.off(GameEvent.EVENT_MAP_LOAD_COMPLETE, this.onAnimationComplete, this);
+    }
 }
 
 tgxModuleContext.attachImplClass(UI_BattleMatch, UI_BattleMatch_Impl);

+ 2 - 2
assets/module_storm_sunder/Script/Enum/GameEvent.ts

@@ -1,6 +1,6 @@
 export class GameEvent {
-    /** 通知UI实例化*/
-    static readonly EVENT_UI_INITILIZE = 'EVENT_UI_INITILIZE';
+    /** 地图加载完成*/
+    static readonly EVENT_MAP_LOAD_COMPLETE = 'EVENT_MAP_LOAD_COMPLETE';
     /** 游戏开始*/
     static readonly EVENT_GAME_START = 'EVENT_GAME_START';
     /**龙卷风重置*/

+ 2 - 2
assets/module_storm_sunder/Script/Manager/GameMgr.ts

@@ -62,7 +62,7 @@ export class GameMgr {
                 }
                 break;
             case GameStatus.Gambit:
-                await MapMgr.Instance.addMapNode();
+                // await MapMgr.Instance.addMapNode();
                 await PlayerMgr.inst.setPlayerVisible(true);
                 await PlayerMgr.inst.setPlayerPosition();
                 homeMap.active = false;
@@ -86,7 +86,7 @@ export class GameMgr {
                 break;
             case GameStatus.Continue:
                 await PlayerMgr.inst.revivePlayer();
-                await GameUtil.delay(0.2);
+                await GameUtil.delay(0.1);
                 this.setGameStatus(GameStatus.Playing);
                 break;
             case GameStatus.End:

+ 6 - 3
assets/module_storm_sunder/Script/Manager/MapMgr.ts

@@ -6,6 +6,8 @@ import { PlayerMgr } from "./PlayerMgr";
 import { assetManager, instantiate, Prefab } from "cc";
 import { resLoader } from "db://assets/core_tgx/base/ResLoader";
 import { TimerMgr } from "./TimerMgr";
+import { EventDispatcher } from "db://assets/core_tgx/easy_ui_framework/EventDispatcher";
+import { GameEvent } from "../Enum/GameEvent";
 
 export class MapMgr {
     private static _instance: MapMgr;
@@ -17,24 +19,25 @@ export class MapMgr {
     }
 
     //添加地图节点
-    public async addMapNode() {
+    public async addMapNode(): Promise<void> {
         const mapUI = StormSunderGlobalInstance.instance.map;
         const map = await this.loadAsyncMap();
         const node = instantiate(map);
         mapUI.removeAllChildren();
         node.parent = mapUI;
+        EventDispatcher.instance.emit(GameEvent.EVENT_MAP_LOAD_COMPLETE);
     }
 
     //加载地图
     public async loadAsyncMap(): Promise<Prefab> {
-        return new Promise((resolve, reject) => {
+        return new Promise(async (resolve, reject) => {
             const bundle = assetManager.getBundle(resLoader.gameBundleName);
             if (!bundle) {
                 console.error("module_nut is null!");
                 reject();
             }
 
-            resLoader.loadAsync(resLoader.gameBundleName, `Prefabs/Map1`, Prefab).then((prefab: Prefab) => {
+            await resLoader.loadAsync(resLoader.gameBundleName, `Prefabs/Map1`, Prefab).then((prefab: Prefab) => {
                 resolve(prefab);
             })
         })

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

@@ -102,6 +102,6 @@ export class TimerMgr {
 
         const mapConfig = MapMgr.Instance.getMapConfig(1);
         this.countDownTime = mapConfig.time;
-        // this.countDownTime = 5; //测试
+        this.countDownTime = 5; //测试
     }
 }

+ 1 - 3
assets/start/Start.ts

@@ -17,14 +17,12 @@ const _preloadRes = [
     { bundle: ModuleDef.BASIC, url: 'ui_alert/UI_Alert', type: 'prefab' },
     { bundle: ModuleDef.BASIC, url: 'ui_tips/UI_Tips', type: 'prefab' },
     { bundle: ModuleDef.BASIC, url: 'ui_waiting/UI_Waiting', type: 'prefab' },
-    { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Prefabs/Map1', type: 'prefab' },
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Prefabs/Blood', type: 'prefab' },
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Prefabs/PlayerInfo', type: 'prefab' },
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Prefabs/ExpProp', type: 'prefab' },
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Prefabs/LevelUp', type: 'prefab' },
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Prefabs/PkProp', type: 'prefab' },
-    { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Audio/bgm_1.mp3', type: 'audio' },
-    { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Audio/bgm_2.mp3', type: 'audio' },
+    { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Audio/bgm.mp3', type: 'audio' },
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Audio/dianji.mp3', type: 'audio' },
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Audio/luosi.mp3', type: 'audio' },
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Audio/shengli.mp3', type: 'audio' },