From 2234b9021dde66edbc224bbb7a35166e8732c55b Mon Sep 17 00:00:00 2001 From: pan Date: Tue, 21 Jul 2026 16:12:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(MissionCard):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=8B=B1=E9=9B=84=E5=8D=A1=E6=B1=A0=E5=85=B3=E9=97=AD=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增closeHeros节点绑定与点击回调,实现卡池收起逻辑,同步更新卡池显示状态与英雄信息面板。 优化进入准备阶段的交互表现,确保卡池初始状态与手动操作一致。 --- assets/resources/gui/element/mission.prefab | 3 ++ assets/script/game/map/MissionCardComp.ts | 47 ++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/assets/resources/gui/element/mission.prefab b/assets/resources/gui/element/mission.prefab index ad5e8797..99537c0a 100644 --- a/assets/resources/gui/element/mission.prefab +++ b/assets/resources/gui/element/mission.prefab @@ -35577,6 +35577,9 @@ "showHeros": { "__id__": 1772 }, + "closeHeros": { + "__id__": 874 + }, "cards_up": { "__id__": 256 }, diff --git a/assets/script/game/map/MissionCardComp.ts b/assets/script/game/map/MissionCardComp.ts index 1a5c2e5e..ddb07478 100644 --- a/assets/script/game/map/MissionCardComp.ts +++ b/assets/script/game/map/MissionCardComp.ts @@ -102,6 +102,9 @@ export class MissionCardComp extends CCComp { /** 英雄卡牌池cards_node显示隐藏 */ @property(Node) showHeros: Node = null! + /** 关闭英雄卡池按钮(仅负责收起 cards_node) */ + @property(Node) + closeHeros: Node = null! /** 卡池升级按钮节点(已废弃,保留节点引用防止 editor 报错) */ @property(Node) cards_up: Node = null! @@ -188,6 +191,9 @@ export class MissionCardComp extends CCComp { if (this.showHeros && this.showHeros.isValid) { this.showHeros.off(NodeEventType.TOUCH_END, this.onShowHerosClick, this); } + if (this.closeHeros && this.closeHeros.isValid) { + this.closeHeros.off(NodeEventType.TOUCH_END, this.onCloseHerosClick, this); + } this.unbindEvents(); } @@ -289,6 +295,8 @@ export class MissionCardComp extends CCComp { /** 英雄卡池显示/隐藏切换按钮 */ this.showHeros?.on(NodeEventType.TOUCH_END, this.onShowHerosClick, this); + /** 关闭英雄卡池按钮 */ + this.closeHeros?.on(NodeEventType.TOUCH_END, this.onCloseHerosClick, this); /** 技能卡刷新按钮 */ this.skill_refresh?.on(NodeEventType.TOUCH_START, this.onSkillDrawTouchStart, this); @@ -460,6 +468,9 @@ export class MissionCardComp extends CCComp { if (this.showHeros && this.showHeros.isValid) { this.showHeros.off(NodeEventType.TOUCH_END, this.onShowHerosClick, this); } + if (this.closeHeros && this.closeHeros.isValid) { + this.closeHeros.off(NodeEventType.TOUCH_END, this.onCloseHerosClick, this); + } if (this.skill_refresh && this.skill_refresh.isValid) { this.skill_refresh.off(NodeEventType.TOUCH_START, this.onSkillDrawTouchStart, this); this.skill_refresh.off(NodeEventType.TOUCH_END, this.onSkillDrawTouchEnd, this); @@ -593,6 +604,24 @@ export class MissionCardComp extends CCComp { } } + /** + * 关闭英雄卡池按钮回调: + * - 仅负责收起 cards_node,不切换展开态。 + * - 同步关闭 showHeros 下的 "active" 子节点,保持与 toggle 状态一致。 + * - 同步关闭已打开的英雄信息面板(HInfo),避免卡池收起后信息面板孤立悬浮。 + */ + private onCloseHerosClick() { + if (!this.cards_node || !this.cards_node.isValid) return; + oops.audio.playEffect("music/button"); + this.cards_node.active = false; + const activeChild = this.showHeros?.getChildByName("active"); + if (activeChild) { + activeChild.active = false; + } + // 关闭英雄卡池时同步关闭已打开的英雄信息面板 + oops.gui.remove(UIID.HInfo); + } + // ======================== 技能抽卡按钮回调 ======================== private onSkillDrawTouchStart() { this.playButtonPressAnim(this.skill_refresh); @@ -693,19 +722,33 @@ export class MissionCardComp extends CCComp { this.cardsHideScale = new Vec3(0, 0, this.cardsBaseScale.z); } - /** 进入准备阶段:展开卡牌面板(立即恢复缩放,无动画) */ + /** + * 进入准备阶段: + * - 先将卡牌面板置为收起态,激活 showHeros 按钮可见。 + * - 再触发一次 onShowHerosClick(等同玩家点击 showHeros 按钮), + * 让卡池以"按钮点击"的方式展开,保持与玩家手动点击一致的交互表现。 + */ private enterPreparePhase() { if (!this.cards_node || !this.cards_node.isValid) return; this.initCardsPanelPos(); - this.cards_node.active = true; + // 先收起面板,确保后续 onShowHerosClick 能正确切换为展开 Tween.stopAllByTarget(this.cards_node); this.cards_node.setScale(this.cardsShowScale); + this.cards_node.active = false; + // 显式激活「显示英雄卡池」按钮本身,让玩家可见可点 + if (this.showHeros && this.showHeros.isValid) { + this.showHeros.active = true; + const showActive = this.showHeros.getChildByName("active"); + if (showActive) showActive.active = false; + } if (this.cards_chou && this.cards_chou.isValid) { const nobg = this.cards_chou.getChildByName("nobg"); if (nobg) { nobg.active = !this.canDrawCards(); } } + // 触发一次 showHeros 按钮点击效果,自动展开卡池 + this.onShowHerosClick(); } private enterBattlePhase() {