fix(mission): 处理英雄全灭时自动结束战斗并优化UI显示

- 在 MissionComp 中新增 handleHeroWipe 方法,当英雄数量为0且处于战斗状态时自动结束战斗
- 修复 MissionCardComp 中卡池等级UI显示逻辑,简化激活条件判断
- 调整 role_controller.prefab 中多个UI元素的布局参数,优化界面显示效果
This commit is contained in:
walkpan
2026-03-28 18:39:00 +08:00
parent ddce1208ee
commit 99ee713a1f
3 changed files with 68 additions and 44 deletions

View File

@@ -428,43 +428,38 @@ export class MissionCardComp extends CCComp {
}
/** 更新升级按钮上的等级文案,反馈当前卡池层级 */
private updatePoolLvUI() {
if (!this.cards_up) return;
const nobg = this.cards_up.getChildByName("nobg");
if (nobg) {
nobg.active = !this.canUpPool();
}
const coinNode = this.cards_up.getChildByName("coin");
const label = coinNode?.getChildByName("num")?.getComponent(Label);
if (this.poolLv >= CARD_POOL_MAX_LEVEL) {
if (label) {
label.string = `0`;
if (this.cards_up) {
const nobg = this.cards_up.getChildByName("nobg");
if (nobg) {
nobg.active = !this.canUpPool();
}
} else {
if (label) {
label.string = `${this.getUpgradeCost(this.poolLv)}`;
const coinNode = this.cards_up.getChildByName("coin");
const label = coinNode?.getChildByName("num")?.getComponent(Label);
if (this.poolLv >= CARD_POOL_MAX_LEVEL) {
if (label) {
label.string = `0`;
}
} else {
if (label) {
label.string = `${this.getUpgradeCost(this.poolLv)}`;
}
}
}
if (this.pool_lv_node) {
let hasMatchedNode = false;
const children = this.pool_lv_node.children;
for (let i = 0; i < children.length; i++) {
const node = children[i];
const lvText = node.name.match(/\d+/)?.[0];
const lv = lvText ? Number(lvText) : (i + 1);
const active = lv === this.poolLv;
node.active = active;
if (active) {
hasMatchedNode = true;
}
}
if (!hasMatchedNode) {
for (let i = 1; i <= CARD_POOL_MAX_LEVEL; i++) {
const n = this.pool_lv_node.getChildByName(`lv${i}`);
if (n) {
n.active = i === this.poolLv;
}
}
}
this.pool_lv_node.active = true;
const lv = Math.max(CARD_POOL_INIT_LEVEL, Math.min(CARD_POOL_MAX_LEVEL, Math.floor(this.poolLv)));
const lv1 = this.pool_lv_node.getChildByName("lv1");
const lv2 = this.pool_lv_node.getChildByName("lv2");
const lv3 = this.pool_lv_node.getChildByName("lv3");
const lv4 = this.pool_lv_node.getChildByName("lv4");
const lv5 = this.pool_lv_node.getChildByName("lv5");
const lv6 = this.pool_lv_node.getChildByName("lv6");
if (lv1) lv1.active = lv >= 1;
if (lv2) lv2.active = lv >= 2;
if (lv3) lv3.active = lv >= 3;
if (lv4) lv4.active = lv >= 4;
if (lv5) lv5.active = lv >= 5;
if (lv6) lv6.active = lv >= 6;
}
mLogger.log(this.debugMode, "MissionCardComp", "pool lv ui update", {
poolLv: this.poolLv,