181404010226 1 month ago
parent
commit
db6c0d405a

+ 14 - 3
assets/NewbieGuidePlugin-v1.0.0/NewbieGuidePlugin-v1.0.0/scripts/GuideUIController.ts

@@ -738,10 +738,10 @@ export class GuideUIController extends Component {
     private createOrUpdateDynamicMaskForStep(stepIndex: number): void {
         const data = this.getStepData(stepIndex);
         const action = (data.action || 'tap').toLowerCase();
-    
+
         // 是否为拖拽步骤(或具备起点/终点/多目标)
         const isMove = data.category === 'drag' || !!(data.startNode || data.endNode || (data.multiTargets && data.multiTargets.length));
-    
+
         // tap 场景下用于绑定触摸的目标节点(drag 不需要)
         let tapTarget: Node | null = null;
     
@@ -823,7 +823,16 @@ export class GuideUIController extends Component {
             this.applyDynamicMaskRect(stepIndex, centerWorld, width, height);
             tapTarget = target;
         }
-    
+
+        // 在进入步骤前:根据当前步骤类型决定是否允许 confirm 按钮
+        try {
+            const evtName = (data as any).eventName || this.guideStepsEvents[stepIndex] || '';
+            const isConfirmWaitEvent = (action === 'wait_event' && evtName === GameEvents.BLOCK_SELECTION_CONFIRMED);
+            const isConfirmTapTarget = (!isMove && tapTarget && tapTarget.isValid && tapTarget.name && tapTarget.name.toLowerCase() === 'confirm');
+            const allowConfirm = !!(isConfirmWaitEvent || isConfirmTapTarget);
+            EventBus.getInstance().emit(GameEvents.GUIDE_SET_CONFIRM_ENABLED, allowConfirm);
+        } catch (e) { /* 忽略切换异常 */ }
+
         // 清理旧监听(drag/tap 都需要)
         this.clearCurrentStepListeners();
     
@@ -1064,6 +1073,8 @@ export class GuideUIController extends Component {
         if (this.guild1Node && this.guild1Node.parent) {
             this.guild1Node.parent.active = false;
         }
+        // 清除对 confirm 的交互覆盖,恢复正常状态
+        try { EventBus.getInstance().emit(GameEvents.GUIDE_CLEAR_CONFIRM_OVERRIDE); } catch {}
         this._currentStepIndex = -1;
     }
 

+ 1 - 1
assets/Scenes/GameLevel.scene

@@ -10167,7 +10167,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 17.934,
-      "y": -548.039,
+      "y": -559.087,
       "z": 0
     },
     "_lrot": {

+ 37 - 0
assets/scripts/CombatSystem/BlockSelection/GameBlockSelection.ts

@@ -282,6 +282,9 @@ export class GameBlockSelection extends Component {
     // 引导期禁用颜色置灰(HEX: 4D4545)
     private readonly GUIDE_DISABLED_COLOR: Color = new Color(0x4D, 0x45, 0x45, 255);
 
+    // 引导阶段确认按钮交互覆盖:true 启用;false 禁用;null 不覆盖
+    private guideConfirmEnabledOverride: boolean | null = null;
+
     onEnable() {
         // 如果还未初始化,则进行初始化
         if (!this.isInitialized) {
@@ -400,6 +403,10 @@ export class GameBlockSelection extends Component {
         eventBus.on(GameEvents.ENEMY_START_WAVE, this.updateGuideButtonStates, this);
         // 监听:全局强制结束所有拖拽(用于教程自动放置期间收敛拖拽状态)
         eventBus.on(GameEvents.FORCE_END_ALL_DRAGS, this.onForceEndAllDrags, this);
+
+        // 监听:新手引导确认按钮覆盖事件
+        eventBus.on(GameEvents.GUIDE_SET_CONFIRM_ENABLED, this.onGuideSetConfirmEnabledEvent, this);
+        eventBus.on(GameEvents.GUIDE_CLEAR_CONFIRM_OVERRIDE, this.onGuideClearConfirmOverrideEvent, this);
     }
     
     // 处理重置方块选择事件
@@ -408,6 +415,7 @@ export class GameBlockSelection extends Component {
         // 恢复按钮颜色与交互状态,并清理颜色缓存,避免跨关卡残留
         this.applyGuideDisabledVisual(this.addCoinButton, false);
         this.applyGuideDisabledVisual(this.refreshButton, false);
+        this.applyGuideDisabledVisual(this.confirmButton, false);
         this.originalButtonColors.clear();
     }
 
@@ -416,6 +424,7 @@ export class GameBlockSelection extends Component {
         // 恢复按钮颜色与交互状态,并清理颜色缓存,避免跨关卡残留
         this.applyGuideDisabledVisual(this.addCoinButton, false);
         this.applyGuideDisabledVisual(this.refreshButton, false);
+        this.applyGuideDisabledVisual(this.confirmButton, false);
         this.originalButtonColors.clear();
     }
     // 处理游戏开始事件
@@ -679,6 +688,12 @@ export class GameBlockSelection extends Component {
 
     // 确认按钮点击
     public onConfirmButtonClicked() {
+        // 引导阶段需要禁用时直接拦截点击
+        const restrictGuide = this.isGuideRestrictActive();
+        if (this.guideConfirmEnabledOverride === false || (restrictGuide && this.guideConfirmEnabledOverride !== true)) {
+            this.applyGuideDisabledVisual(this.confirmButton, true);
+            return;
+        }
         // 检查是否有上阵方块
         const hasBlocks = this.hasPlacedBlocks();        
         if (!hasBlocks) {
@@ -846,8 +861,30 @@ export class GameBlockSelection extends Component {
         const restrict = this.isGuideRestrictActive();
         this.applyGuideDisabledVisual(this.addCoinButton, restrict);
         this.applyGuideDisabledVisual(this.refreshButton, restrict);
+        // 同步确认按钮禁用(允许由引导覆盖)
+        let confirmDisabled = restrict;
+        if (this.guideConfirmEnabledOverride !== null) {
+            confirmDisabled = !this.guideConfirmEnabledOverride;
+        }
+        this.applyGuideDisabledVisual(this.confirmButton, confirmDisabled);
     };
 
+    // 引导:设置确认按钮启用/禁用覆盖
+    private onGuideSetConfirmEnabledEvent(enabled: boolean) {
+        if (typeof enabled === 'boolean') {
+            this.guideConfirmEnabledOverride = enabled;
+        } else {
+            this.guideConfirmEnabledOverride = null;
+        }
+        this.updateGuideButtonStates();
+    }
+
+    // 引导:清除确认按钮覆盖
+    private onGuideClearConfirmOverrideEvent() {
+        this.guideConfirmEnabledOverride = null;
+        this.updateGuideButtonStates();
+    }
+
     // 显示金币不足UI
     private showInsufficientCoinsUI() {
         // 使用事件机制显示资源不足Toast

+ 4 - 0
assets/scripts/Core/EventBus.ts

@@ -106,6 +106,10 @@ export enum GameEvents {
     // 方块选择事件
     BLOCK_SELECTION_CONFIRMED = 'BLOCK_SELECTION_CONFIRMED',
 
+    // 新手引导:确认按钮交互覆盖
+    GUIDE_SET_CONFIRM_ENABLED = 'GUIDE_SET_CONFIRM_ENABLED',
+    GUIDE_CLEAR_CONFIRM_OVERRIDE = 'GUIDE_CLEAR_CONFIRM_OVERRIDE',
+
     // 教程事件
     TUTORIAL_BLOCK_1_PLACED = 'TUTORIAL_BLOCK_1_PLACED',
     TUTORIAL_BLOCK_2_PLACED = 'TUTORIAL_BLOCK_2_PLACED',