From c9b1583cd2d826bed5bd101acf6a8793efd872b5 Mon Sep 17 00:00:00 2001 From: walkpan Date: Tue, 6 Jan 2026 11:16:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B8=B8=E6=88=8F=E5=9C=B0=E5=9B=BE):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=BB=E5=8A=A1=E5=8D=A1=E7=89=87=E9=94=81?= =?UTF-8?q?=E5=AE=9A=E7=8A=B6=E6=80=81=E5=90=8C=E6=AD=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加isLocked私有变量统一管理锁定状态,确保Lock节点的显示与状态同步 修复初始化时Lock节点显示逻辑,避免初始显示异常 在广告播放成功和关闭时正确更新锁定状态 --- assets/script/game/map/MissionCardComp.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/assets/script/game/map/MissionCardComp.ts b/assets/script/game/map/MissionCardComp.ts index 93f26229..92168364 100644 --- a/assets/script/game/map/MissionCardComp.ts +++ b/assets/script/game/map/MissionCardComp.ts @@ -43,6 +43,9 @@ export class MissionCardComp extends CCComp { // 已购买的卡片槽位标记 (用于物品购买) purchasedSlots: boolean[] = [false, false, false, false, false]; + // 是否处于锁定状态 + private isLocked: boolean = true; + onLoad() { if (this.btnClose) { this.btnClose.on(Node.EventType.TOUCH_END, this.onGiveUp, this); @@ -77,7 +80,8 @@ export class MissionCardComp extends CCComp { /** 游戏开始初始化 */ onMissionStart() { - this.Lock.active = true; + this.isLocked = true; + if (this.Lock) this.Lock.active = false; // 初始不显示,等待 showCardType this.eventQueue = []; } @@ -165,6 +169,11 @@ export class MissionCardComp extends CCComp { this.btnClose.active = (type === CardType.Potion); } + // 根据锁定状态显示 Lock 节点 + if (this.Lock) { + this.Lock.active = this.isLocked; + } + this.resetCardStates(); this.refCards(); this.playShowAnimation(); @@ -365,6 +374,7 @@ export class MissionCardComp extends CCComp { console.log("播放激励视频广告..."); // 模拟广告播放成功回调 + this.isLocked = false; if (this.Lock) { this.Lock.active = false; oops.gui.toast("解锁成功"); @@ -407,6 +417,11 @@ export class MissionCardComp extends CCComp { this.btnClose.active = false; } + // 关闭时隐藏 Lock 节点 + if (this.Lock) { + this.Lock.active = false; + } + this.checkQueue(); }