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];
|
purchasedSlots: boolean[] = [false, false, false, false, false];
|
||||||
|
|
||||||
|
// 是否处于锁定状态
|
||||||
|
private isLocked: boolean = true;
|
||||||
|
|
||||||
onLoad() {
|
onLoad() {
|
||||||
if (this.btnClose) {
|
if (this.btnClose) {
|
||||||
this.btnClose.on(Node.EventType.TOUCH_END, this.onGiveUp, this);
|
this.btnClose.on(Node.EventType.TOUCH_END, this.onGiveUp, this);
|
||||||
@@ -77,7 +80,8 @@ export class MissionCardComp extends CCComp {
|
|||||||
|
|
||||||
/** 游戏开始初始化 */
|
/** 游戏开始初始化 */
|
||||||
onMissionStart() {
|
onMissionStart() {
|
||||||
this.Lock.active = true;
|
this.isLocked = true;
|
||||||
|
if (this.Lock) this.Lock.active = false; // 初始不显示,等待 showCardType
|
||||||
this.eventQueue = [];
|
this.eventQueue = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,6 +169,11 @@ export class MissionCardComp extends CCComp {
|
|||||||
this.btnClose.active = (type === CardType.Potion);
|
this.btnClose.active = (type === CardType.Potion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据锁定状态显示 Lock 节点
|
||||||
|
if (this.Lock) {
|
||||||
|
this.Lock.active = this.isLocked;
|
||||||
|
}
|
||||||
|
|
||||||
this.resetCardStates();
|
this.resetCardStates();
|
||||||
this.refCards();
|
this.refCards();
|
||||||
this.playShowAnimation();
|
this.playShowAnimation();
|
||||||
@@ -365,6 +374,7 @@ export class MissionCardComp extends CCComp {
|
|||||||
console.log("播放激励视频广告...");
|
console.log("播放激励视频广告...");
|
||||||
|
|
||||||
// 模拟广告播放成功回调
|
// 模拟广告播放成功回调
|
||||||
|
this.isLocked = false;
|
||||||
if (this.Lock) {
|
if (this.Lock) {
|
||||||
this.Lock.active = false;
|
this.Lock.active = false;
|
||||||
oops.gui.toast("解锁成功");
|
oops.gui.toast("解锁成功");
|
||||||
@@ -407,6 +417,11 @@ export class MissionCardComp extends CCComp {
|
|||||||
this.btnClose.active = false;
|
this.btnClose.active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 关闭时隐藏 Lock 节点
|
||||||
|
if (this.Lock) {
|
||||||
|
this.Lock.active = false;
|
||||||
|
}
|
||||||
|
|
||||||
this.checkQueue();
|
this.checkQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user