From 190cbc4281026f73e2ea8e994f574018e7361625 Mon Sep 17 00:00:00 2001 From: walkpan Date: Sat, 3 Jan 2026 23:28:31 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=AF=84=E5=88=86=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B8=B8=E6=88=8F=E8=AF=84=E5=88=86=E6=A0=87?= =?UTF-8?q?=E5=87=86=E9=85=8D=E7=BD=AE=E5=92=8C=E7=BB=93=E7=AE=97=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加 ScoreSet.ts 配置文件定义评分权重和等级阈值 在 VictoryComp.ts 中实现总分计算逻辑,根据战斗行为、伤害、击杀等多项指标计算最终得分 --- assets/script/game/common/config/ScoreSet.ts | 48 ++++++++++++++++++++ assets/script/game/map/VictoryComp.ts | 46 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 assets/script/game/common/config/ScoreSet.ts diff --git a/assets/script/game/common/config/ScoreSet.ts b/assets/script/game/common/config/ScoreSet.ts new file mode 100644 index 00000000..bfd5657e --- /dev/null +++ b/assets/script/game/common/config/ScoreSet.ts @@ -0,0 +1,48 @@ +/** + * 游戏评分标准配置 + * 定义各统计指标的分数权重 + */ +export const ScoreWeights = { + // ========== 战斗行为权重 ========== + CRT_KILL: 5, // 每次暴击得分 + WF_TRIGGER: 10, // 每次风怒得分 + DODGE_SUCCESS: 20, // 每次闪避得分 + BACK_SUCCESS: 5, // 每次击退得分 + STUN_SUCCESS: 8, // 每次击晕得分 + FREEZE_SUCCESS: 8, // 每次冰冻得分 + + // ========== 伤害权重 ========== + // 总伤害转化分 (每 X 点伤害得 1 分) + DMG_FACTOR: 0.01, + // 平均伤害加成 (每点平均伤害得 X 分) + AVG_DMG_FACTOR: 0.5, + // 反伤伤害转化 (每点反伤得 X 分) + THORNS_DMG_FACTOR: 0.02, + // 暴击伤害转化 (每点暴击伤害得 X 分) + CRIT_DMG_FACTOR: 0.015, + + // ========== 击杀权重 ========== + KILL_MELEE: 10, // 普通近战怪击杀 + KILL_REMOTE: 15, // 远程怪击杀 + KILL_ELITE: 100, // 精英怪击杀 + KILL_BOSS: 1000, // Boss击杀 + + // ========== 生存权重 ========== + HEAL_FACTOR: 0.2, // 治疗量转化分 + LIFESTEAL_FACTOR: 0.3, // 吸血量转化分 + + // ========== 资源权重 ========== + EXP_FACTOR: 0.1, // 经验值转化分 + GOLD_FACTOR: 0.5, // 金币转化分 +}; + +/** + * 评分等级阈值 + */ +export enum ScoreRank { + S = 10000, + A = 5000, + B = 2000, + C = 1000, + D = 0 +} diff --git a/assets/script/game/map/VictoryComp.ts b/assets/script/game/map/VictoryComp.ts index 4af40988..fa89d924 100644 --- a/assets/script/game/map/VictoryComp.ts +++ b/assets/script/game/map/VictoryComp.ts @@ -9,6 +9,7 @@ import { HeroAttrsComp } from "../hero/HeroAttrsComp"; import { HeroViewComp } from "../hero/HeroViewComp"; import { FacSet } from "../common/config/GameSet"; import { Attrs } from "../common/config/HeroAttrs"; +import { ScoreWeights } from "../common/config/ScoreSet"; const { ccclass, property } = _decorator; @@ -53,6 +54,51 @@ export class VictoryComp extends CCComp { this.node.getChildByName("btns").getChildByName("next").active=!args.can_revive this.node.getChildByName("btns").getChildByName("alive").active=args.can_revive + + // 只有在不能复活(彻底结算)时才计算总分 + if (!this.canRevive) { + this.calculateTotalScore(); + } + } + + /** + * 计算单局总分并更新到 smc.scores.score + */ + private calculateTotalScore() { + const s = smc.vmdata.scores; + let totalScore = 0; + + // 1. 战斗行为分 + totalScore += s.crt_count * ScoreWeights.CRT_KILL; + totalScore += s.wf_count * ScoreWeights.WF_TRIGGER; + totalScore += s.dod_count * ScoreWeights.DODGE_SUCCESS; + totalScore += s.back_count * ScoreWeights.BACK_SUCCESS; + totalScore += s.stun_count * ScoreWeights.STUN_SUCCESS; + totalScore += s.freeze_count * ScoreWeights.FREEZE_SUCCESS; + + // 2. 伤害转化分 + totalScore += s.total_dmg * ScoreWeights.DMG_FACTOR; + totalScore += s.avg_dmg * ScoreWeights.AVG_DMG_FACTOR; + totalScore += s.thorns_dmg * ScoreWeights.THORNS_DMG_FACTOR; + totalScore += s.crit_dmg_total * ScoreWeights.CRIT_DMG_FACTOR; + + // 3. 击杀得分 + totalScore += s.melee_kill_count * ScoreWeights.KILL_MELEE; + totalScore += s.remote_kill_count * ScoreWeights.KILL_REMOTE; + totalScore += s.elite_kill_count * ScoreWeights.KILL_ELITE; + totalScore += s.boss_kill_count * ScoreWeights.KILL_BOSS; + + // 4. 生存得分 + totalScore += s.heal_total * ScoreWeights.HEAL_FACTOR; + totalScore += s.lifesteal_total * ScoreWeights.LIFESTEAL_FACTOR; + + // 5. 资源得分 + totalScore += s.exp_total * ScoreWeights.EXP_FACTOR; + totalScore += s.gold_total * ScoreWeights.GOLD_FACTOR; + + // 更新总分(向下取整) + s.score = Math.floor(totalScore); + console.log(`[VictoryComp] 结算总分: ${s.score}`); }