refactor(map): 移除技能框背景节点相关代码
1. 删除SskillBoxComp中bg_node属性和updateBgNode方法 2. 精简prefab中冗余的节点配置 3. 修复CardLiteComp的canup渲染覆盖问题
This commit is contained in:
@@ -80,6 +80,8 @@ export class CardLiteComp extends CCComp {
|
||||
this.bindEvents();
|
||||
this.opacityComp = this.node.getComponent(UIOpacity) || this.node.addComponent(UIOpacity);
|
||||
this.opacityComp.opacity = 255;
|
||||
// onLoad 在 addChild 时才触发,晚于 setHeroByUuid;此处按已赋值的数据重新判定 canup,避免覆盖渲染结果
|
||||
this.refreshCanUp();
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
@@ -104,6 +106,7 @@ export class CardLiteComp extends CCComp {
|
||||
this.card_uuid = uuid;
|
||||
this.node.active = true;
|
||||
this.applyHeroUI(hero);
|
||||
this.refreshCanUp();
|
||||
mLogger.log(this.debugMode, "CardLiteComp", "setHeroByUuid", { uuid });
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,6 @@ export class SSkillBoxComp extends CCComp {
|
||||
@property({ type: Node })
|
||||
private icon_node: Node = null;
|
||||
|
||||
/** 技能图标节点:下面有 green blue purple red yellow 5个不同颜色节点*/
|
||||
@property({ type: Node })
|
||||
private bg_node: Node = null;
|
||||
|
||||
/** 技能等级标签 */
|
||||
@property(Label)
|
||||
private lv_label: Label = null;
|
||||
@@ -136,27 +132,6 @@ export class SSkillBoxComp extends CCComp {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据技能等级切换 bg_node 下的颜色子节点显示。
|
||||
* 等级与颜色对应关系:
|
||||
* 技能卡档位:card_lv 1 (wave 1) → green,2 (wave 5) → blue,3 (wave 8) → purple
|
||||
* 英雄技能等级:s_lv 1~5 → green / blue / purple / red / yellow
|
||||
*/
|
||||
private updateBgNode() {
|
||||
if (!this.bg_node) return;
|
||||
const lvToColor: Record<number, string> = {
|
||||
1: "green",
|
||||
2: "blue",
|
||||
3: "purple",
|
||||
4: "red",
|
||||
5: "yellow",
|
||||
};
|
||||
const targetColor = lvToColor[this.card_lv];
|
||||
this.bg_node.children.forEach(child => {
|
||||
child.active = (child.name === targetColor);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析技能名称:
|
||||
* 1. 显式设置的卡牌名(最高优先级);
|
||||
@@ -228,15 +203,11 @@ export class SSkillBoxComp extends CCComp {
|
||||
|
||||
/**
|
||||
* 更新 UI:
|
||||
* - 背景:根据技能等级切换对应颜色子节点显示
|
||||
* - 图标:从 uicons 图集获取
|
||||
* - 名称标签:显示技能名称
|
||||
* - 等级标签:显示技能等级(Lv.x 样式)
|
||||
*/
|
||||
updateUI() {
|
||||
// 按技能等级切换背景颜色节点(与 getLvColor 等级配色一致)
|
||||
this.updateBgNode();
|
||||
|
||||
// 加载技能图标
|
||||
if (this.icon_node) {
|
||||
// 优先使用卡牌自定义 icon;未定义则按图鉴模式 / 装备卡 trigger_type 自动取
|
||||
|
||||
Reference in New Issue
Block a user