From 50c9205e0fd8346b7356e23241da899de091f6c7 Mon Sep 17 00:00:00 2001 From: pan Date: Fri, 11 Sep 2026 11:20:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor(missionComp):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E6=97=A7=E7=9A=84phase=5Flabel=EF=BC=8C=E6=94=B9=E7=94=A8MVVM?= =?UTF-8?q?=E9=A9=B1=E5=8A=A8=E8=BF=9B=E5=BA=A6=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重构了关卡进度倒计时和阶段显示的UI更新逻辑,移除了直接绑定的phase_label组件,改为通过vmdata驱动VMLabel自动更新,统一了进度显示的维护方式。 --- assets/script/game/map/MissionComp.ts | 30 +++++++-------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/assets/script/game/map/MissionComp.ts b/assets/script/game/map/MissionComp.ts index d2512a2c..4d42bbe5 100644 --- a/assets/script/game/map/MissionComp.ts +++ b/assets/script/game/map/MissionComp.ts @@ -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) {