Browse Source

PlayerMgr

woso_javan 2 months ago
parent
commit
b1f47b6277

+ 47 - 0
assets/module_storm_sunder/Script/Manager/PlayerMgr.ts

@@ -0,0 +1,47 @@
+import { assetManager, instantiate, Prefab, Node, UITransform, Vec3, Vec2, view, game, PhysicsSystem, geometry } from "cc";
+import { resLoader } from "db://assets/core_tgx/base/ResLoader";
+import { StormSunderGlobalInstance } from "../StormSunderGlobalInstance";
+import { TornadoComponent } from "../Component/TornadoComponent";
+
+const propRes = [
+    "Prefabs/Props/altman",
+    "Prefabs/Props/aula",
+    "Prefabs/Props/clown",
+]
+
+/** 龙卷风管理器*/
+export class PlayerMgr {
+    private static _instance: PlayerMgr;
+    public static get Instance(): PlayerMgr {
+        if (this._instance == null) {
+            this._instance = new PlayerMgr();
+        }
+        return this._instance;
+    }
+
+    public static get inst(): PlayerMgr {
+        return this.Instance;
+    }
+
+    public tornadoNode: Node = null;//玩家节点
+
+    public genaratorInitialData() {
+        //DOTO 取配置 先定义假数据
+    }
+
+    //获取玩家龙卷风节点
+    async getTornadoNode(): Promise<Node> {
+        return new Promise((resolve, reject) => {
+            if (this.tornadoNode) {
+                resolve(this.tornadoNode);
+            } else {
+                const playersUI = StormSunderGlobalInstance.instance.players!;
+                if (playersUI && playersUI.children.length > 0)
+                    this.tornadoNode = playersUI.children.filter(child => child.getComponent(TornadoComponent))[0];
+
+                resolve(this.tornadoNode);
+            }
+        })
+    }
+}
+

+ 9 - 0
assets/module_storm_sunder/Script/Manager/PlayerMgr.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "4.0.23",
+  "importer": "typescript",
+  "imported": true,
+  "uuid": "b33abbc7-e93d-4aca-b90f-fed1496584e5",
+  "files": [],
+  "subMetas": {},
+  "userData": {}
+}

+ 3 - 2
assets/module_storm_sunder/Script/Manager/PropMgr.ts

@@ -2,6 +2,7 @@ import { assetManager, instantiate, Prefab, Node, UITransform, Vec3, Vec2, view,
 import { resLoader } from "db://assets/core_tgx/base/ResLoader";
 import { StormSunderGlobalInstance } from "../StormSunderGlobalInstance";
 import { TornadoComponent } from "../Component/TornadoComponent";
+import { PlayerMgr } from "./PlayerMgr";
 
 const propRes = [
     "Prefabs/Props/altman",
@@ -9,7 +10,7 @@ const propRes = [
     "Prefabs/Props/clown",
 ]
 
-/** 道具生成管理器*/
+/** 道具管理器*/
 export class PropMgr {
     private static _instance: PropMgr;
     public static get Instance(): PropMgr {
@@ -65,7 +66,7 @@ export class PropMgr {
         if (this.curMovePropsCount >= this.propMaxNum) return;
 
         const propsUI = StormSunderGlobalInstance.instance.props!;
-        this.tornadoNode = this.getTornadoNode();
+        this.tornadoNode = await PlayerMgr.inst.getTornadoNode();
 
         for (let index = 0; index < this.propInitNum; index++) {
             let spawnPos = this.getValidSpawnPosition();