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

@@ -1924,7 +1924,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"x": -240,
"y": 37.166,
"z": 0
},
@@ -1965,7 +1965,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 400,
"width": 240,
"height": 45
},
"_anchorPoint": {
@@ -2079,7 +2079,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"x": -240,
"y": 37.166,
"z": 0
},
@@ -2129,7 +2129,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -137.5,
"x": -87.5,
"y": 0,
"z": 0
},
@@ -2170,8 +2170,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 35,
"height": 35
"width": 30,
"height": 30
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -2265,7 +2265,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -82.5,
"x": -52.5,
"y": 0,
"z": 0
},
@@ -2306,8 +2306,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 35,
"height": 35
"width": 30,
"height": 30
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -2401,7 +2401,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -27.5,
"x": -17.5,
"y": 0,
"z": 0
},
@@ -2442,8 +2442,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 35,
"height": 35
"width": 30,
"height": 30
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -2537,7 +2537,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 27.5,
"x": 17.5,
"y": 0,
"z": 0
},
@@ -2578,8 +2578,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 35,
"height": 35
"width": 30,
"height": 30
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -2673,7 +2673,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 82.5,
"x": 52.5,
"y": 0,
"z": 0
},
@@ -2714,8 +2714,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 35,
"height": 35
"width": 30,
"height": 30
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -2809,7 +2809,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 137.5,
"x": 87.5,
"y": 0,
"z": 0
},
@@ -2850,8 +2850,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 35,
"height": 35
"width": 30,
"height": 30
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -2936,7 +2936,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 310,
"width": 205,
"height": 50
},
"_anchorPoint": {
@@ -2974,7 +2974,7 @@
"_paddingRight": 0,
"_paddingTop": 0,
"_paddingBottom": 0,
"_spacingX": 20,
"_spacingX": 5,
"_spacingY": 0,
"_verticalDirection": 1,
"_horizontalDirection": 0,
@@ -2997,8 +2997,6 @@
"__id__": 0
},
"fileId": "33rSVysAVB1LO2v7wC2zZ1",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
@@ -3043,7 +3041,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"x": -240,
"y": 37.166,
"z": 0
},
@@ -3093,7 +3091,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -137.5,
"x": -87.5,
"y": 0,
"z": 0
},
@@ -3134,8 +3132,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 35,
"height": 35
"width": 30,
"height": 30
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -3229,7 +3227,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -82.5,
"x": -52.5,
"y": 0,
"z": 0
},
@@ -3270,8 +3268,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 35,
"height": 35
"width": 30,
"height": 30
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -3365,7 +3363,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -27.5,
"x": -17.5,
"y": 0,
"z": 0
},
@@ -3406,8 +3404,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 35,
"height": 35
"width": 30,
"height": 30
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -3501,7 +3499,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 27.5,
"x": 17.5,
"y": 0,
"z": 0
},
@@ -3542,8 +3540,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 35,
"height": 35
"width": 30,
"height": 30
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -3637,7 +3635,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 82.5,
"x": 52.5,
"y": 0,
"z": 0
},
@@ -3678,8 +3676,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 35,
"height": 35
"width": 30,
"height": 30
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -3773,7 +3771,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 137.5,
"x": 87.5,
"y": 0,
"z": 0
},
@@ -3814,8 +3812,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 35,
"height": 35
"width": 30,
"height": 30
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -3900,7 +3898,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 310,
"width": 205,
"height": 50
},
"_anchorPoint": {
@@ -3926,7 +3924,7 @@
"__prefab": {
"__id__": 167
},
"_resizeMode": 0,
"_resizeMode": 1,
"_layoutType": 1,
"_cellSize": {
"__type__": "cc.Size",
@@ -3938,7 +3936,7 @@
"_paddingRight": 0,
"_paddingTop": 0,
"_paddingBottom": 0,
"_spacingX": 20,
"_spacingX": 5,
"_spacingY": 0,
"_verticalDirection": 1,
"_horizontalDirection": 0,
@@ -3961,8 +3959,6 @@
"__id__": 0
},
"fileId": "50nlTzRABGJ4vZYBkdXijK",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
@@ -3998,7 +3994,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -271.695,
"x": 240,
"y": 38.592,
"z": 0
},
@@ -4089,7 +4085,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 150,
"width": 240,
"height": 45
},
"_anchorPoint": {
@@ -4160,8 +4156,6 @@
"__id__": 0
},
"fileId": "ebDo8RYmhKJoLQcsDOvm6d",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
@@ -4922,7 +4916,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 120,
"width": 240,
"height": 50
},
"_anchorPoint": {
@@ -5024,7 +5018,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 272.07,
"x": 0,
"y": 38.592,
"z": 0
},
@@ -5115,7 +5109,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 150,
"width": 240,
"height": 45
},
"_anchorPoint": {
@@ -5186,8 +5180,6 @@
"__id__": 0
},
"fileId": "35dr0lJV9CO5Ld8TLk7eCZ",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
@@ -5213,7 +5205,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -44.229,
"x": -71.736,
"y": 0,
"z": 0
},
@@ -5325,8 +5317,6 @@
"__id__": 0
},
"fileId": "e7dPNasr5IyqES0tbwxJX3",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
@@ -5355,7 +5345,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 10,
"x": -49.32,
"y": 0,
"z": 0
},
@@ -5401,7 +5391,7 @@
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"x": 0,
"y": 0.5
},
"_id": ""
@@ -5433,7 +5423,7 @@
"a": 255
},
"_string": "{{0}}",
"_horizontalAlign": 1,
"_horizontalAlign": 0,
"_verticalAlign": 1,
"_actualFontSize": 25,
"_fontSize": 25,
@@ -5511,8 +5501,6 @@
"__id__": 0
},
"fileId": "65zRY1wpZPNLTXws9hsdcE",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
@@ -5529,7 +5517,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 120,
"width": 240,
"height": 50
},
"_anchorPoint": {

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", {