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

@@ -15,12 +15,10 @@ import { _decorator, Animation, AnimationClip, Node, Sprite, Vec3, resources } f
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { HeroInfo } from "../common/config/heroSet";
import { CARD_LV_BG_COLORS } from "../common/config/GameSet";
const { ccclass, property } = _decorator;
/** card_lv → BG_node 子节点颜色名映射1=green 2=blue 3=purple 4=yellow 5=red */
const BG_COLORS = ["green", "blue", "purple", "yellow", "red"];
/**
* ChipComp —— 单张英雄卡图标/背景视图组件
*
@@ -58,7 +56,7 @@ export class ChipComp extends CCComp {
// 背景:按 card_lv 切换颜色底框green/blue/purple/yellow/red
if (this.BG_node) {
const color = BG_COLORS[Math.min(Math.max(hero.card_lv ?? 1, 1), 5) - 1];
const color = CARD_LV_BG_COLORS[Math.min(Math.max(hero.card_lv ?? 1, 1), 5) - 1];
this.BG_node.children.forEach(child => child.active = (child.name === color));
}