Browse Source

右侧杯移除 触发 事件

woso_javan 3 months ago
parent
commit
214efe13b4

+ 1 - 1
assets/module_take_goblet/Script/Component/OutArea.ts

@@ -45,7 +45,7 @@ export class OutArea extends Component {
             try {
                 // 执行补满动画并等待完成
                 await cocktailCup.fillUp();
-                console.log('最右侧杯子已补满');
+                EventDispatcher.instance.emit(GameEvent.EVENT_RIGHT_CUP_FULL);
             } catch (e) {
                 console.error('补满操作失败:', e);
             }

+ 3 - 0
assets/module_take_goblet/Script/Enum/GameEvent.ts

@@ -19,6 +19,9 @@ export class GameEvent {
     /** 按钮功能 补满事件*/
     static readonly EVENT_FILL_UP = 'EVENT_FILL_UP';
 
+    /** 右侧杯子已补满*/
+    static readonly EVENT_RIGHT_CUP_FULL = 'EVENT_RIGHT_CUP_FULL';
+
     /** 检测游戏是否结束*/
     static readonly EVENT_CHECK_GAME_OVER = 'EVENT_CHECK_GAME_OVER';
 

+ 2 - 0
assets/module_take_goblet/Script/LevelAction.ts

@@ -74,6 +74,7 @@ export class LevelAction extends Component {
             }
         }, this);
         EventDispatcher.instance.on(GameEvent.EVENT_COCKTAIL_CUP_DESTROYED, this.handleCupDestroyed, this);
+        EventDispatcher.instance.on(GameEvent.EVENT_RIGHT_CUP_FULL, this.addWaitCupToOutArea, this);
     }
 
     unregisterListener() {
@@ -81,6 +82,7 @@ export class LevelAction extends Component {
         EventDispatcher.instance.off(GameEvent.EVENT_CLICK_ORIGIN_CUP, this.handlePourOriginCup, this);
         EventDispatcher.instance.off(GameEvent.EVENT_ORIGIN_CUP_DESTROYED, this.spawnNewOriginCup, this);
         EventDispatcher.instance.off(GameEvent.EVENT_COCKTAIL_CUP_DESTROYED, this.handleCupDestroyed, this);
+        EventDispatcher.instance.off(GameEvent.EVENT_RIGHT_CUP_FULL, this.addWaitCupToOutArea, this);
     }
 
     private async generateInitialCups() {