refactor(config,map): 统一抽离卡片背景颜色配置
将多处硬编码的卡片等级背景颜色数组移至公共配置文件, 同时重构英雄列表组件的等级显示逻辑,替换为标签直接赋值。
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user