refactor(TalentItemComp): 优化天赋卡牌UI显示逻辑

1.  复用CardConfig中的pool_lv统一卡牌背景色,与技能卡保持一致
2.  新增对驻场天赋卡的图标显示支持,使用FieldSkillSet获取图标
3.  重构图标获取逻辑,与SCardComp保持对齐避免显示异常
4.  移除冗余的wave映射背景色代码
This commit is contained in:
pan
2026-06-22 16:24:23 +08:00
parent a8642cb788
commit 72cdf32a75
2 changed files with 384 additions and 71 deletions

View File

@@ -22,32 +22,32 @@
"__id__": 2 "__id__": 2
}, },
{ {
"__id__": 35 "__id__": 63
}, },
{ {
"__id__": 41 "__id__": 69
}, },
{ {
"__id__": 47 "__id__": 75
}, },
{ {
"__id__": 53 "__id__": 81
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 59 "__id__": 87
}, },
{ {
"__id__": 61 "__id__": 89
}, },
{ {
"__id__": 63 "__id__": 91
} }
], ],
"_prefab": { "_prefab": {
"__id__": 65 "__id__": 93
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -169,6 +169,48 @@
}, },
{ {
"__id__": 34 "__id__": 34
},
{
"__id__": 35
},
{
"__id__": 37
},
{
"__id__": 39
},
{
"__id__": 41
},
{
"__id__": 43
},
{
"__id__": 45
},
{
"__id__": 47
},
{
"__id__": 49
},
{
"__id__": 51
},
{
"__id__": 53
},
{
"__id__": 55
},
{
"__id__": 57
},
{
"__id__": 59
},
{
"__id__": 61
} }
], ],
"removedComponents": [] "removedComponents": []
@@ -474,6 +516,280 @@
], ],
"value": 0 "value": 0
}, },
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 36
},
"propertyPath": [
"_active"
],
"value": true
},
{
"__type__": "cc.TargetInfo",
"localID": [
"4aTybcwdBL1IFgubnxRuUh"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 38
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size",
"width": 220,
"height": 270
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"eedc9qvxRPQpepecxrSorR"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 40
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size",
"width": 440,
"height": 540
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"deY6hTveBKBIzSn0k9oD+7"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 42
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size",
"width": 432,
"height": 528
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"b7HYchf9tMK7WtemLDPjlE"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 44
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size",
"width": 190,
"height": 140
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"25j0n7apFBratTNBweGTa7"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 46
},
"propertyPath": [
"_lpos"
],
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": 50,
"z": 0
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"93O2t0s3dBQYpkATdTKBPZ"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 48
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size",
"width": 380,
"height": 280
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"1fWMnHXs1IPZv24wLXcOc2"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 50
},
"propertyPath": [
"_active"
],
"value": true
},
{
"__type__": "cc.TargetInfo",
"localID": [
"34+q4uHrVMer4aH0jqs5JM"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 52
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size",
"width": 220,
"height": 270
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"2bJbEaLWxKYIZXGRHTBM1m"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 54
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size",
"width": 440,
"height": 540
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"8b8xEuZsBB+KDupKZRRki9"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 56
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size",
"width": 432,
"height": 528
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"30uXpT+kpFI5rT0dm/gN9k"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 58
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size",
"width": 190,
"height": 140
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"c6lDSuSgFMJaDP3gZWwz54"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 60
},
"propertyPath": [
"_lpos"
],
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": 50,
"z": 0
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"24Xd/896JIz4KMqBZHi94n"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 62
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size",
"width": 380,
"height": 280
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"1dy2U4eNdI6KgBqcoGyOOb"
]
},
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "icon", "_name": "icon",
@@ -486,14 +802,14 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 36 "__id__": 64
}, },
{ {
"__id__": 38 "__id__": 66
} }
], ],
"_prefab": { "_prefab": {
"__id__": 40 "__id__": 68
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -530,11 +846,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 35 "__id__": 63
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 37 "__id__": 65
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -558,11 +874,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 35 "__id__": 63
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 39 "__id__": 67
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@@ -625,14 +941,14 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 42 "__id__": 70
}, },
{ {
"__id__": 44 "__id__": 72
} }
], ],
"_prefab": { "_prefab": {
"__id__": 46 "__id__": 74
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -669,11 +985,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 41 "__id__": 69
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 43 "__id__": 71
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -697,11 +1013,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 41 "__id__": 69
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 45 "__id__": 73
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@@ -784,14 +1100,14 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 48 "__id__": 76
}, },
{ {
"__id__": 50 "__id__": 78
} }
], ],
"_prefab": { "_prefab": {
"__id__": 52 "__id__": 80
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -828,11 +1144,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 47 "__id__": 75
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 49 "__id__": 77
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -856,11 +1172,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 47 "__id__": 75
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 51 "__id__": 79
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@@ -943,14 +1259,14 @@
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 54 "__id__": 82
}, },
{ {
"__id__": 56 "__id__": 84
} }
], ],
"_prefab": { "_prefab": {
"__id__": 58 "__id__": 86
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -987,11 +1303,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 53 "__id__": 81
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 55 "__id__": 83
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -1015,11 +1331,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 53 "__id__": 81
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 57 "__id__": 85
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@@ -1100,7 +1416,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 60 "__id__": 88
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -1128,7 +1444,7 @@
}, },
"_enabled": false, "_enabled": false,
"__prefab": { "__prefab": {
"__id__": 62 "__id__": 90
}, },
"_alignFlags": 40, "_alignFlags": 40,
"_target": null, "_target": null,
@@ -1164,16 +1480,16 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 64 "__id__": 92
}, },
"lbl_name": { "lbl_name": {
"__id__": 44 "__id__": 72
}, },
"lbl_info": { "lbl_info": {
"__id__": 50 "__id__": 78
}, },
"icon": { "icon": {
"__id__": 38 "__id__": 66
}, },
"bg": null, "bg": null,
"_id": "" "_id": ""
@@ -1194,7 +1510,7 @@
"instance": null, "instance": null,
"targetOverrides": [ "targetOverrides": [
{ {
"__id__": 66 "__id__": 94
} }
], ],
"nestedPrefabInstanceRoots": [ "nestedPrefabInstanceRoots": [
@@ -1206,7 +1522,7 @@
{ {
"__type__": "cc.TargetOverrideInfo", "__type__": "cc.TargetOverrideInfo",
"source": { "source": {
"__id__": 63 "__id__": 91
}, },
"sourceInfo": null, "sourceInfo": null,
"propertyPath": [ "propertyPath": [
@@ -1216,7 +1532,7 @@
"__id__": 2 "__id__": 2
}, },
"targetInfo": { "targetInfo": {
"__id__": 67 "__id__": 95
} }
}, },
{ {

View File

@@ -15,7 +15,7 @@ import { _decorator, Label, Sprite, SpriteFrame } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { CardConfig } from "../common/config/CardSet"; import { CardConfig } from "../common/config/CardSet";
import { SkillSet } from "../common/config/SkillSet"; import { FieldSkillSet, SkillSet } from "../common/config/SkillSet";
import { CardBgComp } from "./CardBgComp"; import { CardBgComp } from "./CardBgComp";
import { smc } from "../common/SingletonModuleComp"; import { smc } from "../common/SingletonModuleComp";
import { oops } from "db://oops-framework/core/Oops"; import { oops } from "db://oops-framework/core/Oops";
@@ -49,34 +49,31 @@ export class TalentItemComp extends CCComp {
if (this.lbl_name) this.lbl_name.string = config.name ?? ""; if (this.lbl_name) this.lbl_name.string = config.name ?? "";
if (this.lbl_info) this.lbl_info.string = config.info ?? ""; if (this.lbl_info) this.lbl_info.string = config.info ?? "";
// 根据 wave 映射背景颜色 // 直接复用 CardSet 中已映射好的 pool_lv保证与技能卡牌背景一致
// 1=绿色(poolLv=1) 5=蓝色(poolLv=2) 10=紫色(poolLv=3) 15=黄色(poolLv=4) 20=红色(poolLv=5) // CardSet 通过 waveToPoolLv[wave] 由 SKILL_CARD_WAVES 索引推导wave 1→1, 5→2, 8→3
if (this.bg) { if (this.bg) {
let poolLv = 1; this.bg.apply(config.pool_lv || 1);
const wave = config.wave || 1;
if (wave >= 20) poolLv = 5;
else if (wave >= 15) poolLv = 4;
else if (wave >= 10) poolLv = 3;
else if (wave >= 5) poolLv = 2;
else poolLv = 1;
this.bg.apply(poolLv);
} }
// 设置图标 // 设置图标:驻场卡(skill=undefined 但有 field)走 FieldSkillSet否则走 SkillSet
if (this.icon && config.skill) { // 与 SCardComp 保持一致,避免驻场卡无 icon 显示
const skillData = SkillSet[config.skill]; if (this.icon) {
if (skillData && skillData.icon) { let iconId: string | undefined;
if (!config.skill && config.field && config.field.length > 0) {
// 驻场卡:用 FieldSkillSet[field[0]].icon
const fieldUuid = config.field[0];
iconId = FieldSkillSet[fieldUuid]?.icon || `${fieldUuid}`;
} else if (config.skill) {
// 技能卡:用 SkillSet[skill].icon
iconId = SkillSet[config.skill]?.icon;
}
if (iconId) {
if (smc.uiconsAtlas) { if (smc.uiconsAtlas) {
const frame = smc.uiconsAtlas.getSpriteFrame(skillData.icon); const frame = smc.uiconsAtlas.getSpriteFrame(iconId);
if (frame) { if (frame) this.icon.spriteFrame = frame;
this.icon.spriteFrame = frame;
}
} else { } else {
const sf = oops.res.get("game/heros/cards/" + skillData.icon, SpriteFrame) as SpriteFrame; const sf = oops.res.get("game/heros/cards/" + iconId, SpriteFrame) as SpriteFrame;
if (sf) { if (sf) this.icon.spriteFrame = sf;
this.icon.spriteFrame = sf;
}
} }
} }
} }