diff --git a/assets/script/game/map/MissionCardComp.ts b/assets/script/game/map/MissionCardComp.ts index bdfbe42e..fcf98e66 100644 --- a/assets/script/game/map/MissionCardComp.ts +++ b/assets/script/game/map/MissionCardComp.ts @@ -89,28 +89,38 @@ export class MissionCardComp extends CCComp { // 是否已经选择了天赋 private hasSelected: boolean = false; + // 事件队列 + private eventQueue: CardType[] = []; + private onShopOpen(event: string, args: any) { - this.node.active = true; - this.hasSelected = false; - this.curCardType = CardType.Potion; - this.resetCardStates(); - this.refCards(); - this.playShowAnimation(); + this.eventQueue.push(CardType.Potion); + this.checkQueue(); } private onTalentSelect(event: string, args: any) { - this.node.active = true; - this.hasSelected = false; // 重置选择状态 - this.curCardType = CardType.Talent; // 记录当前类型为天赋 - this.resetCardStates(); // 每次刷新前重置卡片状态 - this.refCards(); - this.playShowAnimation(); + this.eventQueue.push(CardType.Talent); + this.checkQueue(); } private onHeroSkillSelect(event: string, args: any) { + this.eventQueue.push(CardType.Skill); + this.checkQueue(); + } + + private checkQueue() { + if (this.node.active) return; + if (this.eventQueue.length === 0) return; + + const type = this.eventQueue.shift(); + if (type) { + this.showCardType(type); + } + } + + private showCardType(type: CardType) { this.node.active = true; this.hasSelected = false; - this.curCardType = CardType.Skill; + this.curCardType = type; this.resetCardStates(); this.refCards(); this.playShowAnimation(); @@ -336,6 +346,7 @@ export class MissionCardComp extends CCComp { */ close() { this.node.active = false; + this.checkQueue(); } /** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */