Răsfoiți Sursa

fffffffffffffffff

woso_javan 3 luni în urmă
părinte
comite
70e115bd5a

+ 1 - 2
assets/module_take_goblet/Script/Component/OriginCup.ts

@@ -29,8 +29,8 @@ export class OriginCup extends Component {
     }
 
     destroyOriginCup() {
-        // 在销毁前记录位置
         const id = this.node.uuid;
+        console.log('销毁原浆杯id : ', id);
         tween(this.node)
             .to(0.3, { scale: Vec3.ZERO })
             .call(() => {
@@ -38,7 +38,6 @@ export class OriginCup extends Component {
                 this.node.destroy();
             })
             .start();
-
     }
 }
 

+ 6 - 32
assets/module_take_goblet/Script/LevelAction.ts

@@ -30,8 +30,8 @@ export class LevelAction extends Component {
     private originCupPositions = new Map<string, Vec3>(); // 改用唯一ID记录
 
     start() {
-        this.registerListener();
         this.generateInitialCups();
+        this.registerListener();
     }
 
     onDestroy() {
@@ -41,9 +41,9 @@ export class LevelAction extends Component {
     registerListener() {
         EventDispatcher.instance.on(GameEvent.EVENT_CLICK_ORIGIN_CUP, this.handlePourOriginCup, this);
         EventDispatcher.instance.on(GameEvent.EVENT_ORIGIN_CUP_DESTROYED, (uuid: string) => {
-            const cupNode = find(uuid) as Node;
-            if (cupNode) {
-                this.spawnNewOriginCup(cupNode);
+            const targetPos = this.originCupPositions.get(uuid);
+            if (targetPos) {
+                this.spawnNewOriginCup(targetPos);
             }
         }, this);
         EventDispatcher.instance.on(GameEvent.EVENT_COCKTAIL_CUP_DESTROYED, this.handleCupDestroyed, this);
@@ -125,7 +125,7 @@ export class LevelAction extends Component {
             // 在生成初始原浆杯时记录位置
             const id = originCupNode.uuid; // 使用节点唯一ID
             this.originCupPositions.set(id, originCupNode.position.clone());
-            // console.log('在生成初始原浆杯时记录位置: ', originCupNode.position);
+            console.log('在生成初始原浆杯时记录id : ', id, originCupNode.position);
         });
     }
 
@@ -294,11 +294,7 @@ export class LevelAction extends Component {
         }
     }
 
-    private async spawnNewOriginCup(destroyedCup: Node) {
-        // 获取被销毁杯子的初始位置
-        const id = destroyedCup.uuid;
-        const targetPos = this.originCupPositions.get(id) || Vec3.ZERO;
-
+    private async spawnNewOriginCup(targetPos: Vec3) {
         // 创建新原浆杯
         const height = TakeGobletGlobalInstance.instance.generateOriginCupHeight();
         const prefab = await TakeGobletGlobalInstance.instance.loadAsyncOriginCup(height);
@@ -354,28 +350,6 @@ export class LevelAction extends Component {
     private handleCupDestroyed(destroyedCup: Node) {
         // 从outArea移除被销毁的杯子
         this.outArea.removeCup(destroyedCup);
-        // 补充新杯子到等待区
-        this.generateNewCupToWaitArea();
-    }
-
-    private async generateNewCupToWaitArea() {
-        const configs = TakeGobletGlobalInstance.instance.getInitialCupsConfig();
-        const randomConfig = configs[Math.floor(Math.random() * configs.length)];
-
-        const prefab = await TakeGobletGlobalInstance.instance.loadAsyncCocktail(randomConfig.height);
-        const newCup = instantiate(prefab);
-        const cupComp = newCup.getComponent(CocktailCup)!;
-
-        cupComp.cupColor = TakeGobletGlobalInstance.instance.getRandomColor();
-        cupComp.reset();
-
-        this.waitArea.addCup(newCup);
-    }
-
-    // 新增重置方法
-    public resetLevel() {
-        this.originCupPositions.clear();
-        this.generateInitialCups();
     }
 }