fix(herobox): 修复英雄框默认激活状态并添加等级背景切换逻辑
1. 将herobox预制体的默认激活状态从true改为false 2. 新增ebars_node装备图标节点绑定 3. 添加根据英雄等级切换背景颜色子节点的逻辑
This commit is contained in:
@@ -2345,7 +2345,7 @@
|
||||
"propertyPath": [
|
||||
"_active"
|
||||
],
|
||||
"value": true
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"__type__": "CCPropertyOverrideInfo",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -44,6 +44,10 @@ export class HeroBoxComp extends CCComp {
|
||||
|
||||
// ======================== 编辑器绑定节点 ========================
|
||||
|
||||
/** 装备图标节点 */
|
||||
@property({ type: Node })
|
||||
private ebars_node: Node = null;
|
||||
|
||||
/** 英雄图标节点 */
|
||||
@property({ type: Node })
|
||||
private icon_node: Node = null;
|
||||
@@ -516,6 +520,9 @@ export class HeroBoxComp extends CCComp {
|
||||
const heroUuid = this.model.hero_uuid ?? 0;
|
||||
const hero = HeroInfo[heroUuid];
|
||||
|
||||
// ---- 背景(按 card_lv 切换 bg_node 颜色子节点) ----
|
||||
this.updateBgNode(hero?.card_lv ?? 1);
|
||||
|
||||
// ---- 名称 ----
|
||||
if (this.name_label && this.name_label.isValid) {
|
||||
this.name_label.string = this.model.hero_name ?? "";
|
||||
@@ -566,6 +573,31 @@ export class HeroBoxComp extends CCComp {
|
||||
|
||||
// ======================== 内部工具 ========================
|
||||
|
||||
/**
|
||||
* 根据 card_lv 切换 bg_node 下的颜色子节点显示。
|
||||
* 等级与颜色对应关系:
|
||||
* card_lv 1 → green
|
||||
* card_lv 2 → blue
|
||||
* card_lv 3 → purple
|
||||
* card_lv 4 → red
|
||||
* card_lv 5 → yellow
|
||||
* @param cardLv 英雄卡牌等级(HeroInfo.card_lv,缺省按 1 处理)
|
||||
*/
|
||||
private updateBgNode(cardLv: number) {
|
||||
if (!this.bg_node || !this.bg_node.isValid) return;
|
||||
const lvToColor: Record<number, string> = {
|
||||
1: "green",
|
||||
2: "blue",
|
||||
3: "purple",
|
||||
4: "red",
|
||||
5: "yellow",
|
||||
};
|
||||
const targetColor = lvToColor[cardLv] ?? lvToColor[1];
|
||||
this.bg_node.children.forEach(child => {
|
||||
child.active = (child.name === targetColor);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计场上存活英雄数量(与 MissionCardComp.getAliveHeroCount 口径一致)。
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user