feat(MissionCard): 添加英雄卡池关闭按钮功能

新增closeHeros节点绑定与点击回调,实现卡池收起逻辑,同步更新卡池显示状态与英雄信息面板。
优化进入准备阶段的交互表现,确保卡池初始状态与手动操作一致。
This commit is contained in:
pan
2026-07-21 16:12:38 +08:00
parent d279ef19d8
commit 2234b9021d
2 changed files with 48 additions and 2 deletions

View File

@@ -35577,6 +35577,9 @@
"showHeros": {
"__id__": 1772
},
"closeHeros": {
"__id__": 874
},
"cards_up": {
"__id__": 256
},

View File

@@ -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() {