fix: 修复任务卡牌池等级显示错误并调整角色控制器UI布局

- 修复 MissionCardComp 中等级节点匹配逻辑,避免因节点命名不一致导致的显示错误
- 调整 role_controller.prefab 中多个UI元素的位置、尺寸和间距,优化布局
This commit is contained in:
walkpan
2026-03-28 15:01:21 +08:00
parent 105082d009
commit ddce1208ee
2 changed files with 82 additions and 74 deletions

View File

@@ -433,17 +433,37 @@ export class MissionCardComp extends CCComp {
if (nobg) {
nobg.active = !this.canUpPool();
}
const label = this.cards_up.getChildByName("coin").getChildByName("num").getComponent(Label);
if (!label) return;
const coinNode = this.cards_up.getChildByName("coin");
const label = coinNode?.getChildByName("num")?.getComponent(Label);
if (this.poolLv >= CARD_POOL_MAX_LEVEL) {
label.string = `0`;
if (label) {
label.string = `0`;
}
} else {
label.string = `${this.getUpgradeCost(this.poolLv)}`;
if (label) {
label.string = `${this.getUpgradeCost(this.poolLv)}`;
}
}
if (this.pool_lv_node) {
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;
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;
}
}
}
}
mLogger.log(this.debugMode, "MissionCardComp", "pool lv ui update", {