feat(rogue): 添加基于等级的怪物经验计算函数

- 新增 calculateMonsterExp 函数,根据怪物ID和等级动态计算经验值
- 替换 MissionComp 中硬编码的经验值逻辑,使用新的计算函数
- 设计经验增长公式以平衡升级曲线,目标让玩家在13分钟左右达到20级
This commit is contained in:
panw
2026-01-28 17:01:29 +08:00
parent 940211d465
commit 624c8a6c4e
2 changed files with 17 additions and 13 deletions

View File

@@ -4,7 +4,7 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { MonsterCost, MonType, calculateMonsterGold, getLevelExp } from "./RogueConfig";
import { MonsterCost, MonType, calculateMonsterGold, getLevelExp, calculateMonsterExp } from "./RogueConfig";
import { GameEvent } from "../common/config/GameEvent";
import { HeroViewComp } from "../hero/HeroViewComp";
import { UIID } from "../common/config/GameUIConfig";
@@ -130,18 +130,7 @@ export class MissionComp extends CCComp {
}
// 计算经验
let exp = 10; // 基础经验
switch (type) {
case MonType.BOSS:
exp = 200;
break;
case MonType.ELITE:
exp = 50;
break;
default:
exp = 10;
break;
}
let exp = calculateMonsterExp(data.uuid, level);
smc.addExp(exp);
this.cal_gold_reward(data, type);

View File

@@ -372,6 +372,21 @@ export function calculateMonsterGold(uuid: number, level: number, type: MonType)
return gold;
}
/**
* 计算怪物经验值
* 目标让玩家在13分钟左右升到20级
* @param uuid 怪物ID
* @param level 怪物等级
*/
export function calculateMonsterExp(uuid: number, level: number): number {
const cost = MonsterCost[uuid] || 1;
// 基础系数 0.8,成长因子 1.1
// 这样设计是为了对抗升级所需经验的指数增长 (1.2^L),同时平衡刷怪数量的线性增长
// T=0 (Lv1): Unit Exp ≈ 0.8
// T=13 (Lv14): Unit Exp ≈ 0.8 * 1.1^13 ≈ 2.76
return Math.max(1, Math.floor(cost * 0.8 * Math.pow(1.1, level - 1)));
}
// 怪物消耗点数配置
export const MonsterCost: Record<number, number> = {
5201: 1, // 兽人战士 (Warrior)