diff --git a/assets/script/game/map/MissionCardComp.ts b/assets/script/game/map/MissionCardComp.ts index 44c60f81..210bd666 100644 --- a/assets/script/game/map/MissionCardComp.ts +++ b/assets/script/game/map/MissionCardComp.ts @@ -1,4 +1,4 @@ -import { _decorator, Label, Node, tween, Vec3, Color, Sprite } from "cc"; +import { _decorator, Label, Node, tween, Vec3, Color, Sprite, Tween } from "cc"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; @@ -47,7 +47,8 @@ export class MissionCardComp extends CCComp { oops.message.on(GameEvent.TalentSelect, this.onTalentSelect, this); oops.message.on(GameEvent.HeroSkillSelect, this.onHeroSkillSelect, this); oops.message.on(GameEvent.ShopOpen, this.onShopOpen, this); - oops.message.on(GameEvent.MissionStart, this.init, this); + oops.message.on(GameEvent.MissionStart, this.onMissionStart, this); + oops.message.on(GameEvent.MissionEnd, this.onMissionEnd, this); oops.message.on(GameEvent.ToCallFriend, this.onCallFriend, this); } @@ -56,15 +57,38 @@ export class MissionCardComp extends CCComp { oops.message.off(GameEvent.TalentSelect, this.onTalentSelect, this); oops.message.off(GameEvent.HeroSkillSelect, this.onHeroSkillSelect, this); oops.message.off(GameEvent.ShopOpen, this.onShopOpen, this); - oops.message.off(GameEvent.MissionStart, this.init, this); + oops.message.off(GameEvent.MissionStart, this.onMissionStart, this); + oops.message.off(GameEvent.MissionEnd, this.onMissionEnd, this); oops.message.off(GameEvent.ToCallFriend, this.onCallFriend, this); this.ent.destroy(); } init(){ - this.Lock.active=true + this.onMissionStart(); + } + + /** 游戏开始初始化 */ + onMissionStart() { + this.Lock.active = true; this.eventQueue = []; } + + /** 游戏结束清理 */ + onMissionEnd() { + this.eventQueue = []; + this.node.active = false; + this.hasSelected = false; + + // 停止所有卡片动画 + const cards = [this.card1, this.card2, this.card3, this.card4]; + cards.forEach(card => { + if (card) { + Tween.stopAllByTarget(card); + const selected = card.getChildByName("selected"); + if (selected) Tween.stopAllByTarget(selected); + } + }); + } start() { // 初始隐藏或显示逻辑 this.node.active = false;