refactor(config,map): 统一抽离卡片背景颜色配置

将多处硬编码的卡片等级背景颜色数组移至公共配置文件,
同时重构英雄列表组件的等级显示逻辑,替换为标签直接赋值。
This commit is contained in:
panFD
2026-08-23 23:52:20 +08:00
parent bef521683c
commit 41842f2b67
5 changed files with 25 additions and 37 deletions

View File

@@ -24,10 +24,8 @@ 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 { GameEvent } from "../common/config/GameEvent";
import { HERO_UPGRADE_NEED_FRAGMENTS } from "../common/config/GameSet";
import { CardBgComp } from "./CardBgComp";
import { HERO_UPGRADE_NEED_FRAGMENTS, CARD_LV_BG_COLORS } from "../common/config/GameSet";
import { CardLiteComp } from "./CardLiteComp";
import { ChipComp } from "./ChipComp";
import { smc } from "../common/SingletonModuleComp";
@@ -70,8 +68,9 @@ export class HerosListComp extends CCComp {
@property(Prefab)
card_lite_prefab = null!
@property(Node)
lv_node = null!
/** 卡池等级 Label直接显示 lv.X */
@property(Label)
lv_label = null!
@property(Node)
type_node = null!
@@ -270,14 +269,13 @@ export class HerosListComp extends CCComp {
this.updateGrowthPanel(uuid)
}
private updatePoolLvBg(poolLv: number) {
private updatePoolLvBg(card_lv: number) {
if (!this.BG_node) return
const kindName = CKind[CKind.Hero];
// BG_node 下直接放置颜色节点green/blue/purple/yellow/red按卡池等级激活对应颜色
const color = CARD_LV_BG_COLORS[Math.min(card_lv, 5) - 1]
this.BG_node.children.forEach(child => {
child.active = (child.name === kindName);
const bg = child.getComponent(CardBgComp);
if (bg) child.active ? bg.apply(poolLv) : bg.clear();
});
child.active = (child.name === color)
})
}
private updateCdDisplay(hero: typeof HeroInfo[number]) {
@@ -291,20 +289,8 @@ export class HerosListComp extends CCComp {
}
private updateLvDisplay(hero: typeof HeroInfo[number]) {
if (!this.lv_node) return
const cardLvStr = `lv${hero.card_lv ?? 1}`
this.lv_node.active = true
this.lv_node.children.forEach(child => {
child.active = (child.name === cardLvStr)
})
const widget = this.lv_node.getComponent(Widget)
if (widget) widget.updateAlignment()
this.lv_node.children.forEach(child => {
const childWidget = child.getComponent(Widget)
if (childWidget) childWidget.updateAlignment()
})
if (!this.lv_label) return
this.lv_label.string = `lv.${hero.card_lv ?? 1}`
}
private updateTypeDisplay(hero: typeof HeroInfo[number]) {