feat(结算): 添加最高分记录判定与UI显示
在胜利结算时,增加最高分记录判定逻辑。当当前局分数超过历史最高分时,更新存储并标记为新记录。同时,在总分UI旁显示"new"标识以提示玩家打破了记录。
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
// 通用渲染单个维度的函数
|
||||
|
||||
Reference in New Issue
Block a user