diff --git a/assets/script/game/map/VictoryComp.ts b/assets/script/game/map/VictoryComp.ts index d0afd4cc..1a03e07d 100644 --- a/assets/script/game/map/VictoryComp.ts +++ b/assets/script/game/map/VictoryComp.ts @@ -442,8 +442,23 @@ export class VictoryComp extends CCComp { highlightBonus += item.config.scoreBonus; } - // 取整并存储 + // 取整并存储当前局分数 s.score = Math.floor(s.score_combat + s.score_output + s.score_defense + s.score_build + s.score_efficiency + highlightBonus); + + // 判定是否打破历史最高分记录 + let isNewRecord = false; + if (s.score > smc.data.score) { + smc.data.score = s.score; + isNewRecord = true; + // 更新云端/本地存储,保存新记录 + if (typeof smc.updateCloudData === "function") { + smc.updateCloudData(); + } + } + + // 借用 scores 对象传递新记录标记,供 UI 渲染使用 + (s as any).isNewRecord = isNewRecord; + mLogger.log(this.debugMode, 'VictoryComp', `[VictoryComp] 结算总分: ${s.score}`, { combat: s.score_combat, output: s.score_output, @@ -451,7 +466,8 @@ export class VictoryComp extends CCComp { build: s.score_build, efficiency: s.score_efficiency, highlightBonus: highlightBonus, - achievedHighlights: achieved + achievedHighlights: achieved, + isNewRecord: isNewRecord }); } @@ -465,6 +481,13 @@ export class VictoryComp extends CCComp { // 渲染总分 if (this.total_score_label) { this.total_score_label.string = `${s.score}`; + + // 判定是否是新记录,如果是则激活 new 节点 + const isNewRecord = (s as any).isNewRecord === true; + const newNode = this.total_score_label.node.getChildByName("new"); + if (newNode) { + newNode.active = isNewRecord; + } } // 通用渲染单个维度的函数