refactor(missionComp): 移除旧的phase_label,改用MVVM驱动进度显示
重构了关卡进度倒计时和阶段显示的UI更新逻辑,移除了直接绑定的phase_label组件,改为通过vmdata驱动VMLabel自动更新,统一了进度显示的维护方式。
This commit is contained in:
@@ -93,9 +93,6 @@ export class MissionComp extends CCComp {
|
||||
/** 战斗计时 Label(mm:ss) */
|
||||
@property(Label)
|
||||
time_label: Label = null!
|
||||
/** 阶段/进度显示 Label("第 X 节" / 回合间倒计时) */
|
||||
@property(Label)
|
||||
phase_label: Label = null!
|
||||
@property(Node)
|
||||
tooltip: Node = null!
|
||||
|
||||
@@ -324,22 +321,22 @@ export class MissionComp extends CCComp {
|
||||
return MissionComp.COUNTDOWN_NORMAL;
|
||||
}
|
||||
|
||||
/** 更新倒计时 UI(显示剩余秒数) */
|
||||
/** 更新倒计时:写入 vmdata 驱动 VMLabel 显示("下一节 Xs") */
|
||||
private updateCountdownUI(force: boolean = false) {
|
||||
if (!this.isWaveCountdown) return;
|
||||
const remain = Math.max(0, Math.ceil(this.waveCountdown));
|
||||
if (!force && remain === this.lastTimeSecond) return;
|
||||
this.lastTimeSecond = remain;
|
||||
|
||||
if (this.phase_label && this.phase_label.isValid) {
|
||||
this.phase_label.string = `下一节 ${remain}s`;
|
||||
}
|
||||
// MVVM:借用 section 字段承载倒计时秒数,VMLabel 模板自动刷新
|
||||
smc.vmdata.stage_progress.section = remain;
|
||||
}
|
||||
|
||||
/** 结束回合间倒计时 */
|
||||
/** 结束回合间倒计时(恢复 vmdata 进度镜像,VMLabel 回到"第 X 节"显示) */
|
||||
private stopWaveCountdown() {
|
||||
this.isWaveCountdown = false;
|
||||
this.lastTimeSecond = -1;
|
||||
smc.syncStageProgressToView();
|
||||
}
|
||||
|
||||
// ======================== 奖励与广告 ========================
|
||||
@@ -482,21 +479,8 @@ export class MissionComp extends CCComp {
|
||||
this.playTooltipAnim(phaseName);
|
||||
}
|
||||
|
||||
// 更新阶段显示 UI
|
||||
if (this.phase_label && this.phase_label.isValid) {
|
||||
this.phase_label.string = `第 ${getProgressText(this.currentChapter, this.currentStage, this.currentSection)} 节`;
|
||||
|
||||
// 阶段切换动感表现:只在进入战斗阶段跳动一下,让流程充满心流体验
|
||||
if (targetPhase === MissionPhase.BattleStart) {
|
||||
const labelNode = this.phase_label.node;
|
||||
Tween.stopAllByTarget(labelNode);
|
||||
labelNode.scale = v3(1, 1, 1);
|
||||
tween(labelNode)
|
||||
.to(0.3, { scale: v3(1.2, 1.2, 1) }, { easing: "backOut" })
|
||||
.to(0.2, { scale: v3(1, 1, 1) }, { easing: "sineInOut" })
|
||||
.start();
|
||||
}
|
||||
}
|
||||
// 阶段文本由 VMLabel 绑定 vmdata.stage_progress 自动刷新,此处仅同步数据
|
||||
smc.syncStageProgressToView();
|
||||
|
||||
// 重置状态机的计时器
|
||||
if (this.PhaseTime) {
|
||||
|
||||
Reference in New Issue
Block a user