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!
|
herosPanNode: Node = null!
|
||||||
@property(Node)
|
@property(Node)
|
||||||
herosBoxNode: Node = null!
|
herosBoxNode: Node = null!
|
||||||
|
/** 英雄抽卡面板开启金币费用显示节点 */
|
||||||
|
@property(Node)
|
||||||
|
showHerosCost: Node = null!
|
||||||
|
|
||||||
/** 装备面板显示按钮 */
|
/** 装备面板显示按钮 */
|
||||||
@property(Node)
|
@property(Node)
|
||||||
@@ -116,6 +119,9 @@ export class MissionCardComp extends CCComp {
|
|||||||
equipsBoxNode: Node = null!
|
equipsBoxNode: Node = null!
|
||||||
@property(Prefab)
|
@property(Prefab)
|
||||||
equipPrefab: Prefab = null!
|
equipPrefab: Prefab = null!
|
||||||
|
/** 装备面板开启金币费用显示节点 */
|
||||||
|
@property(Node)
|
||||||
|
showEquipsCost: Node = null!
|
||||||
|
|
||||||
/** 技能面板显示按钮 */
|
/** 技能面板显示按钮 */
|
||||||
@property(Node)
|
@property(Node)
|
||||||
@@ -126,6 +132,9 @@ export class MissionCardComp extends CCComp {
|
|||||||
skillBoxNode: Node = null!
|
skillBoxNode: Node = null!
|
||||||
@property(Prefab)
|
@property(Prefab)
|
||||||
sCardPrefab: Prefab = null!
|
sCardPrefab: Prefab = null!
|
||||||
|
/** 技能面板开启金币费用显示节点 */
|
||||||
|
@property(Node)
|
||||||
|
showSkillsCost: Node = null!
|
||||||
|
|
||||||
/** 药品面板显示按钮 */
|
/** 药品面板显示按钮 */
|
||||||
@property(Node)
|
@property(Node)
|
||||||
@@ -136,6 +145,9 @@ export class MissionCardComp extends CCComp {
|
|||||||
shopBoxNode: Node = null!
|
shopBoxNode: Node = null!
|
||||||
@property(Prefab)
|
@property(Prefab)
|
||||||
itemPrefab: Prefab = null!
|
itemPrefab: Prefab = null!
|
||||||
|
/** 药品面板开启金币费用显示节点 */
|
||||||
|
@property(Node)
|
||||||
|
showShopCost: Node = null!
|
||||||
|
|
||||||
/** 技能刷新按钮节点 */
|
/** 技能刷新按钮节点 */
|
||||||
@property(Node)
|
@property(Node)
|
||||||
@@ -1127,20 +1139,24 @@ export class MissionCardComp extends CCComp {
|
|||||||
this.updatePanelOpenCostUI();
|
this.updatePanelOpenCostUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 刷新 4 个显示按钮上的开启费用显示(按钮下无 cost/num 标签子节点时自动跳过) */
|
/** 刷新 4 个显示按钮上的开启金币费用显示 */
|
||||||
private updatePanelOpenCostUI() {
|
private updatePanelOpenCostUI() {
|
||||||
const buttons = this.getPanelShowButtons();
|
const costNodes = this.getPanelCostNodes();
|
||||||
for (let i = 0; i < buttons.length; i++) {
|
for (let i = 0; i < costNodes.length; i++) {
|
||||||
const btn = buttons[i];
|
const node = costNodes[i];
|
||||||
if (!btn || !btn.isValid) continue;
|
if (!node || !node.isValid) continue;
|
||||||
const costNode = btn.getChildByName("cost") ?? btn.getChildByName("num");
|
const label = node.getComponent(Label);
|
||||||
const label = costNode ? costNode.getComponent(Label) : null;
|
|
||||||
if (label) {
|
if (label) {
|
||||||
label.string = `${this.panelOpenCosts[i] ?? MissionCardComp.PANEL_OPEN_BASE_COST}`;
|
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
|
* 显示卡牌面板:缩放从 0 动画放大到 1
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user