From 9a2ad300ea5171ddafd8b05e9d7f7b1547417097 Mon Sep 17 00:00:00 2001 From: walkpan Date: Mon, 5 Jan 2026 23:21:13 +0800 Subject: [PATCH] =?UTF-8?q?refactor(game/map):=20=E6=8B=86=E5=88=86?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=BC=80=E5=A7=8B=E5=92=8C=E7=BB=93=E6=9D=9F?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=88=B0=E7=8B=AC=E7=AB=8B=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将原init方法拆分为onMissionStart和onMissionEnd方法,分别处理任务开始和结束时的逻辑 新增任务结束事件监听,清理动画和状态 --- assets/script/game/map/MissionCardComp.ts | 32 ++++++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) 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;