refactor(map): 重构任务卡片面板金币费用显示逻辑
1. 新增四个面板的费用显示节点绑定属性 2. 拆分原更新方法,提取获取费用节点的独立函数 3. 优化注释和代码结构,提升可维护性
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -106,6 +106,9 @@ export class MissionCardComp extends CCComp {
|
||||
herosPanNode: Node = null!
|
||||
@property(Node)
|
||||
herosBoxNode: Node = null!
|
||||
/** 英雄抽卡面板开启金币费用显示节点 */
|
||||
@property(Node)
|
||||
showHerosCost: Node = null!
|
||||
|
||||
/** 装备面板显示按钮 */
|
||||
@property(Node)
|
||||
@@ -116,6 +119,9 @@ export class MissionCardComp extends CCComp {
|
||||
equipsBoxNode: Node = null!
|
||||
@property(Prefab)
|
||||
equipPrefab: Prefab = null!
|
||||
/** 装备面板开启金币费用显示节点 */
|
||||
@property(Node)
|
||||
showEquipsCost: Node = null!
|
||||
|
||||
/** 技能面板显示按钮 */
|
||||
@property(Node)
|
||||
@@ -126,6 +132,9 @@ export class MissionCardComp extends CCComp {
|
||||
skillBoxNode: Node = null!
|
||||
@property(Prefab)
|
||||
sCardPrefab: Prefab = null!
|
||||
/** 技能面板开启金币费用显示节点 */
|
||||
@property(Node)
|
||||
showSkillsCost: Node = null!
|
||||
|
||||
/** 药品面板显示按钮 */
|
||||
@property(Node)
|
||||
@@ -136,6 +145,9 @@ export class MissionCardComp extends CCComp {
|
||||
shopBoxNode: Node = null!
|
||||
@property(Prefab)
|
||||
itemPrefab: Prefab = null!
|
||||
/** 药品面板开启金币费用显示节点 */
|
||||
@property(Node)
|
||||
showShopCost: Node = null!
|
||||
|
||||
/** 技能刷新按钮节点 */
|
||||
@property(Node)
|
||||
@@ -1127,20 +1139,24 @@ export class MissionCardComp extends CCComp {
|
||||
this.updatePanelOpenCostUI();
|
||||
}
|
||||
|
||||
/** 刷新 4 个显示按钮上的开启费用显示(按钮下无 cost/num 标签子节点时自动跳过) */
|
||||
/** 刷新 4 个显示按钮上的开启金币费用显示 */
|
||||
private updatePanelOpenCostUI() {
|
||||
const buttons = this.getPanelShowButtons();
|
||||
for (let i = 0; i < buttons.length; i++) {
|
||||
const btn = buttons[i];
|
||||
if (!btn || !btn.isValid) continue;
|
||||
const costNode = btn.getChildByName("cost") ?? btn.getChildByName("num");
|
||||
const label = costNode ? costNode.getComponent(Label) : null;
|
||||
const costNodes = this.getPanelCostNodes();
|
||||
for (let i = 0; i < costNodes.length; i++) {
|
||||
const node = costNodes[i];
|
||||
if (!node || !node.isValid) continue;
|
||||
const label = node.getComponent(Label);
|
||||
if (label) {
|
||||
label.string = `${this.panelOpenCosts[i] ?? MissionCardComp.PANEL_OPEN_BASE_COST}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取 4 个面板开启金币费用显示节点(顺序:0=英雄 1=装备 2=技能 3=药品) */
|
||||
private getPanelCostNodes(): Node[] {
|
||||
return [this.showHerosCost, this.showEquipsCost, this.showSkillsCost, this.showShopCost];
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示卡牌面板:缩放从 0 动画放大到 1
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user