From d1409770d60d89783d1f178eba7293321120da36 Mon Sep 17 00:00:00 2001 From: panw Date: Mon, 5 Jan 2026 15:05:29 +0800 Subject: [PATCH] =?UTF-8?q?refactor(game/map):=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E9=98=9F=E5=88=97=E7=AE=A1=E7=90=86=E5=8D=A1?= =?UTF-8?q?=E7=89=87=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将直接显示卡片的逻辑改为事件队列处理,避免多个卡片显示请求冲突 --- assets/script/game/map/MissionCardComp.ts | 37 +++++++++++++++-------- 1 file changed, 24 insertions(+), 13 deletions(-) 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) 删除组件是触发组件处理自定义释放逻辑 */