refactor(hero card): add card_lv background color logic
1. 新增updateBgNode方法根据card_lv切换英雄背景节点颜色 2. 为所有基础卡牌配置补充缺失的card_lv字段 3. 调整配置项字段顺序保持代码整洁
This commit is contained in:
@@ -292,6 +292,9 @@ export class CHeroComp extends CCComp {
|
||||
}
|
||||
}
|
||||
|
||||
// 背景:按 card_lv 激活对应颜色子节点(1→green 2→blue 3→purple 4→red 5→yellow)
|
||||
this.updateBgNode();
|
||||
|
||||
// 描述词条(最多显示 3 条,对应 fied1/fied2/fied3)
|
||||
const fieldLabels = [this.fied1, this.fied2, this.fied3];
|
||||
const desc = hero?.info || this.cardData.info || "";
|
||||
@@ -321,6 +324,30 @@ export class CHeroComp extends CCComp {
|
||||
this.playEnterAnim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 card_lv 切换 bg_node 下的颜色子节点显示。
|
||||
* 等级与颜色对应关系:
|
||||
* card_lv 1 → green
|
||||
* card_lv 2 → blue
|
||||
* card_lv 3 → purple
|
||||
* card_lv 4 → red
|
||||
* card_lv 5 → yellow
|
||||
*/
|
||||
private updateBgNode() {
|
||||
if (!this.bg_node || !this.cardData) return;
|
||||
const lvToColor: Record<number, string> = {
|
||||
1: "green",
|
||||
2: "blue",
|
||||
3: "purple",
|
||||
4: "red",
|
||||
5: "yellow",
|
||||
};
|
||||
const targetColor = lvToColor[this.cardData.card_lv ?? 1];
|
||||
this.bg_node.children.forEach(child => {
|
||||
child.active = (child.name === targetColor);
|
||||
});
|
||||
}
|
||||
|
||||
// ======================== 动画效果 ========================
|
||||
|
||||
/** 入场动画时长(秒) */
|
||||
|
||||
Reference in New Issue
Block a user