refactor(MissionCard): 优化刷新石数量变更逻辑
1. 调整注释描述,将装备数量改为刷新石数量 2. 新增刷新石数量变化动画播放逻辑 3. 重构刷新石数量变更事件处理方法,支持传递变化数值并触发动画
This commit is contained in:
@@ -156,9 +156,9 @@ export class MissionCardComp extends CCComp {
|
||||
/** 英雄数量显示节点(含 icon + num 子节点) */
|
||||
@property(Node)
|
||||
hero_num_node: Node = null!
|
||||
/** 装备数量显示节点(含 icon + num 子节点) */
|
||||
/** 刷新石数量显示节点(含 icon + num 子节点) */
|
||||
@property(Node)
|
||||
refresh_stone_num_node: Node = null!
|
||||
refresh_stone_num_node: Node = null!
|
||||
|
||||
|
||||
// ======================== 运行时状态 ========================
|
||||
@@ -433,9 +433,14 @@ export class MissionCardComp extends CCComp {
|
||||
}
|
||||
}
|
||||
|
||||
/** 刷新石数量变更:刷新刷新按钮的可用状态与费用显示 */
|
||||
private onRefreshStone() {
|
||||
/** 刷新石数量变更:刷新刷新按钮状态/费用显示,并播放数量变化动画 */
|
||||
private onRefreshStone(event: string, args: any) {
|
||||
const payload = args ?? event;
|
||||
const v = typeof payload === 'number' ? payload : (payload?.delta ?? payload?.value ?? 0);
|
||||
this.updateDrawCostUI();
|
||||
if (v !== 0) {
|
||||
this.playRefreshStoneChangeAnim(v > 0);
|
||||
}
|
||||
}
|
||||
|
||||
/** 战斗开始:保留卡牌面板,允许玩家在战斗阶段继续抽卡和召唤英雄 */
|
||||
@@ -1756,6 +1761,16 @@ export class MissionCardComp extends CCComp {
|
||||
this.playHeroNumNodePop(num, peak);
|
||||
}
|
||||
|
||||
/** 刷新石计数变化动画(与金币一致的 icon+num 弹跳) */
|
||||
private playRefreshStoneChangeAnim(isIncrease: boolean) {
|
||||
if (!this.refresh_stone_num_node || !this.refresh_stone_num_node.isValid) return;
|
||||
const peak = isIncrease ? 1.2 : 1.2;
|
||||
const icon = this.refresh_stone_num_node.getChildByName("icon");
|
||||
if (icon && icon.isValid) this.playHeroNumNodePop(icon, peak);
|
||||
const num = this.refresh_stone_num_node.getChildByName("num");
|
||||
if (num && num.isValid) this.playHeroNumNodePop(num, peak);
|
||||
}
|
||||
|
||||
public setHeroMaxCount(max: number) {
|
||||
const missionData = this.getMissionData();
|
||||
if (!missionData) return;
|
||||
|
||||
Reference in New Issue
Block a user