feat(结算): 添加最高分记录判定与UI显示

在胜利结算时,增加最高分记录判定逻辑。当当前局分数超过历史最高分时,更新存储并标记为新记录。同时,在总分UI旁显示"new"标识以提示玩家打破了记录。
This commit is contained in:
walkpan
2026-04-26 09:05:50 +08:00
parent c5d416c697
commit 6281c0f1b2

View File

@@ -442,8 +442,23 @@ export class VictoryComp extends CCComp {
highlightBonus += item.config.scoreBonus; highlightBonus += item.config.scoreBonus;
} }
// 取整并存储 // 取整并存储当前局分数
s.score = Math.floor(s.score_combat + s.score_output + s.score_defense + s.score_build + s.score_efficiency + highlightBonus); 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}`, { mLogger.log(this.debugMode, 'VictoryComp', `[VictoryComp] 结算总分: ${s.score}`, {
combat: s.score_combat, combat: s.score_combat,
output: s.score_output, output: s.score_output,
@@ -451,7 +466,8 @@ export class VictoryComp extends CCComp {
build: s.score_build, build: s.score_build,
efficiency: s.score_efficiency, efficiency: s.score_efficiency,
highlightBonus: highlightBonus, highlightBonus: highlightBonus,
achievedHighlights: achieved achievedHighlights: achieved,
isNewRecord: isNewRecord
}); });
} }
@@ -465,6 +481,13 @@ export class VictoryComp extends CCComp {
// 渲染总分 // 渲染总分
if (this.total_score_label) { if (this.total_score_label) {
this.total_score_label.string = `${s.score}`; 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;
}
} }
// 通用渲染单个维度的函数 // 通用渲染单个维度的函数