refactor(map): 移除技能框背景节点相关代码
1. 删除SskillBoxComp中bg_node属性和updateBgNode方法 2. 精简prefab中冗余的节点配置 3. 修复CardLiteComp的canup渲染覆盖问题
This commit is contained in:
@@ -472,6 +472,8 @@
|
|||||||
"__id__": 0
|
"__id__": 0
|
||||||
},
|
},
|
||||||
"fileId": "0609p02BxJi4U2Di/K3fcs",
|
"fileId": "0609p02BxJi4U2Di/K3fcs",
|
||||||
|
"instance": null,
|
||||||
|
"targetOverrides": null,
|
||||||
"nestedPrefabInstanceRoots": null
|
"nestedPrefabInstanceRoots": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -524,10 +526,7 @@
|
|||||||
"b": 255,
|
"b": 255,
|
||||||
"a": 255
|
"a": 255
|
||||||
},
|
},
|
||||||
"_spriteFrame": {
|
"_spriteFrame": null,
|
||||||
"__uuid__": "cb93c900-b440-4571-91d1-7da1636e3d73@58f49",
|
|
||||||
"__expectedType__": "cc.SpriteFrame"
|
|
||||||
},
|
|
||||||
"_type": 0,
|
"_type": 0,
|
||||||
"_fillType": 0,
|
"_fillType": 0,
|
||||||
"_sizeMode": 0,
|
"_sizeMode": 0,
|
||||||
@@ -1221,7 +1220,7 @@
|
|||||||
"__id__": 87
|
"__id__": 87
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_active": true,
|
"_active": false,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 93
|
"__id__": 93
|
||||||
@@ -1673,6 +1672,8 @@
|
|||||||
"__id__": 0
|
"__id__": 0
|
||||||
},
|
},
|
||||||
"fileId": "70kRUgd4JHx7ic4UPHFlN9",
|
"fileId": "70kRUgd4JHx7ic4UPHFlN9",
|
||||||
|
"instance": null,
|
||||||
|
"targetOverrides": null,
|
||||||
"nestedPrefabInstanceRoots": null
|
"nestedPrefabInstanceRoots": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -3377,9 +3378,11 @@
|
|||||||
"__id__": 145
|
"__id__": 145
|
||||||
},
|
},
|
||||||
"icon_node": {
|
"icon_node": {
|
||||||
|
"__id__": 105
|
||||||
|
},
|
||||||
|
"bg_node": {
|
||||||
"__id__": 2
|
"__id__": 2
|
||||||
},
|
},
|
||||||
"bg_node": null,
|
|
||||||
"lv_label": {
|
"lv_label": {
|
||||||
"__id__": 124
|
"__id__": 124
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ export class CardLiteComp extends CCComp {
|
|||||||
this.bindEvents();
|
this.bindEvents();
|
||||||
this.opacityComp = this.node.getComponent(UIOpacity) || this.node.addComponent(UIOpacity);
|
this.opacityComp = this.node.getComponent(UIOpacity) || this.node.addComponent(UIOpacity);
|
||||||
this.opacityComp.opacity = 255;
|
this.opacityComp.opacity = 255;
|
||||||
|
// onLoad 在 addChild 时才触发,晚于 setHeroByUuid;此处按已赋值的数据重新判定 canup,避免覆盖渲染结果
|
||||||
|
this.refreshCanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
onDestroy() {
|
onDestroy() {
|
||||||
@@ -104,6 +106,7 @@ export class CardLiteComp extends CCComp {
|
|||||||
this.card_uuid = uuid;
|
this.card_uuid = uuid;
|
||||||
this.node.active = true;
|
this.node.active = true;
|
||||||
this.applyHeroUI(hero);
|
this.applyHeroUI(hero);
|
||||||
|
this.refreshCanUp();
|
||||||
mLogger.log(this.debugMode, "CardLiteComp", "setHeroByUuid", { uuid });
|
mLogger.log(this.debugMode, "CardLiteComp", "setHeroByUuid", { uuid });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,10 +26,6 @@ export class SSkillBoxComp extends CCComp {
|
|||||||
@property({ type: Node })
|
@property({ type: Node })
|
||||||
private icon_node: Node = null;
|
private icon_node: Node = null;
|
||||||
|
|
||||||
/** 技能图标节点:下面有 green blue purple red yellow 5个不同颜色节点*/
|
|
||||||
@property({ type: Node })
|
|
||||||
private bg_node: Node = null;
|
|
||||||
|
|
||||||
/** 技能等级标签 */
|
/** 技能等级标签 */
|
||||||
@property(Label)
|
@property(Label)
|
||||||
private lv_label: Label = null;
|
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. 显式设置的卡牌名(最高优先级);
|
* 1. 显式设置的卡牌名(最高优先级);
|
||||||
@@ -228,15 +203,11 @@ export class SSkillBoxComp extends CCComp {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新 UI:
|
* 更新 UI:
|
||||||
* - 背景:根据技能等级切换对应颜色子节点显示
|
|
||||||
* - 图标:从 uicons 图集获取
|
* - 图标:从 uicons 图集获取
|
||||||
* - 名称标签:显示技能名称
|
* - 名称标签:显示技能名称
|
||||||
* - 等级标签:显示技能等级(Lv.x 样式)
|
* - 等级标签:显示技能等级(Lv.x 样式)
|
||||||
*/
|
*/
|
||||||
updateUI() {
|
updateUI() {
|
||||||
// 按技能等级切换背景颜色节点(与 getLvColor 等级配色一致)
|
|
||||||
this.updateBgNode();
|
|
||||||
|
|
||||||
// 加载技能图标
|
// 加载技能图标
|
||||||
if (this.icon_node) {
|
if (this.icon_node) {
|
||||||
// 优先使用卡牌自定义 icon;未定义则按图鉴模式 / 装备卡 trigger_type 自动取
|
// 优先使用卡牌自定义 icon;未定义则按图鉴模式 / 装备卡 trigger_type 自动取
|
||||||
|
|||||||
Reference in New Issue
Block a user