feat(map): add single panel display logic and barbtn prefab

1. 新增closeAllPanels方法,实现打开面板前自动关闭其他所有面板
2. 为英雄池、技能池、装备商店、商品商店的切换逻辑添加单面板显示校验
3. 新增barbtn按钮预制体及其元数据文件
This commit is contained in:
panFD
2026-07-22 22:04:31 +08:00
parent a7ff1fda84
commit db981e89ce
5 changed files with 5186 additions and 14397 deletions

View File

@@ -519,12 +519,20 @@ export class MissionCardComp extends CCComp {
* 技能卡池显隐切换按钮回调:
* - 仅切换 skill_card_node 的 active 状态,不执行抽卡。
* - 后续刷新需通过技能刷新按钮skill_refresh触发。
* - 打开前关闭其他面板,确保同时只显示一个。
*/
private onShowSkillsClick() {
if (!this.skill_card_node || !this.skill_card_node.isValid) return;
oops.audio.playEffect("music/button");
const visible = !this.skill_card_node.active;
if (visible) {
this.closeAllPanels();
}
this.skill_card_node.active = visible;
const activeChild = this.showSkills?.getChildByName("active");
if (activeChild) {
activeChild.active = visible;
}
}
/** 关闭技能卡池按钮回调 */
@@ -532,6 +540,10 @@ export class MissionCardComp extends CCComp {
if (!this.skill_card_node || !this.skill_card_node.isValid) return;
oops.audio.playEffect("music/button");
this.skill_card_node.active = false;
const activeChild = this.showSkills?.getChildByName("active");
if (activeChild) {
activeChild.active = false;
}
}
// ======================== 商店面板 ========================
@@ -539,11 +551,20 @@ export class MissionCardComp extends CCComp {
/**
* 商店显隐切换按钮回调:
* 切换 shopPanNode 的 active 状态。
* 打开前关闭其他面板,确保同时只显示一个。
*/
private onShowShopClick() {
if (!this.shopPanNode || !this.shopPanNode.isValid) return;
oops.audio.playEffect("music/button");
this.shopPanNode.active = !this.shopPanNode.active;
const visible = !this.shopPanNode.active;
if (visible) {
this.closeAllPanels();
}
this.shopPanNode.active = visible;
const activeChild = this.showShop?.getChildByName("active");
if (activeChild) {
activeChild.active = visible;
}
}
/** 关闭商店按钮回调 */
@@ -551,6 +572,10 @@ export class MissionCardComp extends CCComp {
if (!this.shopPanNode || !this.shopPanNode.isValid) return;
oops.audio.playEffect("music/button");
this.shopPanNode.active = false;
const activeChild = this.showShop?.getChildByName("active");
if (activeChild) {
activeChild.active = false;
}
}
/**
@@ -832,15 +857,59 @@ export class MissionCardComp extends CCComp {
this.playButtonResetAnim(this.cards_chou);
}
/**
* 关闭所有面板(英雄卡池、技能卡池、装备商店、商品商店)。
* 用于打开新面板前确保同时只显示一个面板。
* 同时关闭所有按钮的 active 子节点状态。
*/
private closeAllPanels() {
// 关闭英雄卡池
if (this.cards_node && this.cards_node.isValid) {
this.cards_node.active = false;
}
if (this.showHeros && this.showHeros.isValid) {
const activeChild = this.showHeros.getChildByName("active");
if (activeChild) activeChild.active = false;
}
// 关闭技能卡池
if (this.skill_card_node && this.skill_card_node.isValid) {
this.skill_card_node.active = false;
}
if (this.showSkills && this.showSkills.isValid) {
const activeChild = this.showSkills.getChildByName("active");
if (activeChild) activeChild.active = false;
}
// 关闭装备商店
if (this.equipsPanNode && this.equipsPanNode.isValid) {
this.equipsPanNode.active = false;
}
if (this.showEquips && this.showEquips.isValid) {
const activeChild = this.showEquips.getChildByName("active");
if (activeChild) activeChild.active = false;
}
// 关闭商品商店
if (this.shopPanNode && this.shopPanNode.isValid) {
this.shopPanNode.active = false;
}
if (this.showShop && this.showShop.isValid) {
const activeChild = this.showShop.getChildByName("active");
if (activeChild) activeChild.active = false;
}
}
/**
* 英雄卡池显隐切换按钮回调:
* - 切换 cards_node 的 active 状态。
* - 显示时激活 showHeros 下的 "active" 子节点,隐藏时关闭该子节点。
* - 打开前关闭其他面板,确保同时只显示一个。
*/
private onShowHerosClick() {
if (!this.cards_node || !this.cards_node.isValid) return;
oops.audio.playEffect("music/button");
const visible = !this.cards_node.active;
if (visible) {
this.closeAllPanels();
}
this.cards_node.active = visible;
const activeChild = this.showHeros?.getChildByName("active");
if (activeChild) {
@@ -871,11 +940,20 @@ export class MissionCardComp extends CCComp {
/**
* 装备商店显隐切换按钮回调:
* 切换 equipsPanNode 的 active 状态。
* 打开前关闭其他面板,确保同时只显示一个。
*/
private onShowEquipsClick() {
if (!this.equipsPanNode || !this.equipsPanNode.isValid) return;
oops.audio.playEffect("music/button");
this.equipsPanNode.active = !this.equipsPanNode.active;
const visible = !this.equipsPanNode.active;
if (visible) {
this.closeAllPanels();
}
this.equipsPanNode.active = visible;
const activeChild = this.showEquips?.getChildByName("active");
if (activeChild) {
activeChild.active = visible;
}
}
/** 关闭装备商店按钮回调 */
@@ -883,6 +961,10 @@ export class MissionCardComp extends CCComp {
if (!this.equipsPanNode || !this.equipsPanNode.isValid) return;
oops.audio.playEffect("music/button");
this.equipsPanNode.active = false;
const activeChild = this.showEquips?.getChildByName("active");
if (activeChild) {
activeChild.active = false;
}
}
/**