fix(游戏地图): 修复任务卡片锁定状态同步问题
添加isLocked私有变量统一管理锁定状态,确保Lock节点的显示与状态同步 修复初始化时Lock节点显示逻辑,避免初始显示异常 在广告播放成功和关闭时正确更新锁定状态
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user