|
@@ -6,6 +6,8 @@ import { PropMgr } from "./PropMgr";
|
|
|
import { TimerMgr } from "./TimerMgr";
|
|
|
import { UI_BattleResult } from "db://assets/scripts/UIDef";
|
|
|
import { PlayerMgr } from "./PlayerMgr";
|
|
|
+import { assetManager, instantiate, Prefab } from "cc";
|
|
|
+import { resLoader } from "db://assets/core_tgx/base/ResLoader";
|
|
|
|
|
|
export class GameMgr {
|
|
|
private static _instance: GameMgr;
|
|
@@ -47,6 +49,7 @@ export class GameMgr {
|
|
|
PlayerMgr.inst.reset();
|
|
|
break;
|
|
|
case GameStatus.Playing:
|
|
|
+ await this.addMapNode();
|
|
|
await PlayerMgr.inst.setPlayerVisible(true);
|
|
|
homeUI.active = false;
|
|
|
battleUI.active = true;
|
|
@@ -68,6 +71,29 @@ export class GameMgr {
|
|
|
await PlayerMgr.inst.genareatorAIPlayer();
|
|
|
TimerMgr.inst.startCountdown();
|
|
|
}
|
|
|
+
|
|
|
+ //添加地图节点
|
|
|
+ public async addMapNode() {
|
|
|
+ const mapUI = StormSunderGlobalInstance.instance.map;
|
|
|
+ const map = await this.loadAsyncMap();
|
|
|
+ const node = instantiate(map);
|
|
|
+ node.parent = mapUI;
|
|
|
+ }
|
|
|
+
|
|
|
+ //加载地图
|
|
|
+ public async loadAsyncMap(): Promise<Prefab> {
|
|
|
+ return new Promise((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) => {
|
|
|
+ resolve(prefab);
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export enum GameStatus {
|