refactor(map): 移除冗余的卡池等级节点并重构显示逻辑
1. 删除HInfoComp和CardLiteComp中不再使用的pool_lv相关节点字段 2. 将卡池等级背景色显示逻辑迁移到HerosListComp中统一处理 3. 简化CardLiteComp的节点初始化隐藏逻辑
This commit is contained in:
@@ -24,6 +24,7 @@ import { oops } from "db://oops-framework/core/Oops";
|
||||
import { mLogger } from "../common/Logger";
|
||||
import { HeroInfo, HeroList } from "../common/config/heroSet";
|
||||
import { buildSkillDesc } from "../common/config/HeroSkillDesc";
|
||||
import { CKind } from "../common/config/CardSet";
|
||||
import { CardLiteComp } from "./CardLiteComp";
|
||||
|
||||
const { property, ccclass } = _decorator;
|
||||
@@ -45,6 +46,10 @@ export class HerosListComp extends CCComp {
|
||||
@property(Node)
|
||||
cd_node = null!
|
||||
|
||||
/** 卡牌背景底框节点(按卡池等级切换子节点显示) */
|
||||
@property(Node)
|
||||
BG_node=null!
|
||||
|
||||
@property(Node)
|
||||
info_node = null!
|
||||
|
||||
@@ -199,11 +204,32 @@ export class HerosListComp extends CCComp {
|
||||
if (infoLabel) infoLabel.string = desc || hero.info || ""
|
||||
}
|
||||
|
||||
this.updatePoolLvBg(hero.pool_lv ?? 1)
|
||||
this.updateLvDisplay(hero)
|
||||
this.updateTypeDisplay(hero)
|
||||
this.updateHeroAnimation(uuid)
|
||||
}
|
||||
|
||||
private updatePoolLvBg(poolLv: number) {
|
||||
if (!this.BG_node) return
|
||||
const poolColorNames = ["green", "blue", "purple", "yellow", "red"];
|
||||
const poolColorIdx = Math.min(poolLv, 5) - 1;
|
||||
const activeColor = poolColorNames[poolColorIdx];
|
||||
const kindName = CKind[CKind.Hero];
|
||||
this.BG_node.children.forEach(child => {
|
||||
child.active = (child.name === kindName);
|
||||
if (child.active) {
|
||||
child.children.forEach(colorChild => {
|
||||
colorChild.active = (colorChild.name === activeColor);
|
||||
});
|
||||
} else {
|
||||
child.children.forEach(colorChild => {
|
||||
colorChild.active = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private updateCdDisplay(hero: typeof HeroInfo[number]) {
|
||||
if (!this.cd_node) return
|
||||
const skillKeys = Object.keys(hero.skills)
|
||||
|
||||
Reference in New Issue
Block a user