refactor(game): 简化怪物生成逻辑并移除肉鸽配置

- 移除 RogueConfig 及相关动态成长系统
- 简化 Monster.load() 方法参数,直接使用 heroSet 配置
- 移除 MissionMonComp 中的波次生成逻辑和特殊队列
- 清理 MissionComp 中与肉鸽相关的特殊刷怪检查
- 调整 heroSet 配置,移除 buff 字段并统一技能
- 更新技能配置,增加更多攻击特效
This commit is contained in:
panw
2026-03-17 15:59:44 +08:00
parent 8667656e48
commit 8505522c7e
6 changed files with 153 additions and 633 deletions

View File

@@ -4,7 +4,6 @@ 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, calculateMonsterExp, SpecialMonsterSchedule } from "./RogueConfig";
import { GameEvent } from "../common/config/GameEvent";
import { HeroViewComp } from "../hero/HeroViewComp";
import { UIID } from "../common/config/GameUIConfig";
@@ -69,7 +68,6 @@ export class MissionComp extends CCComp {
private readonly skillViewMatcher = ecs.allOf(SkillView);
// 记录已触发的特殊刷怪索引
private spawnedSpecialIndices: Set<number> = new Set();
onLoad(){
this.on(GameEvent.MissionStart,this.mission_start,this)
@@ -86,9 +84,7 @@ export class MissionComp extends CCComp {
if(smc.mission.stop_mon_action) return
smc.vmdata.mission_data.fight_time+=dt
this.FightTime-=dt
// 检查特殊刷怪时间
this.checkSpecialSpawns(smc.vmdata.mission_data.fight_time);
this.update_time();
this.updateMemoryPanel(dt);
}
@@ -106,90 +102,6 @@ export class MissionComp extends CCComp {
this.lastTimeStr = str;
}
}
private checkSpecialSpawns(fightTime: number) {
SpecialMonsterSchedule.forEach((item, index) => {
if (!this.spawnedSpecialIndices.has(index) && fightTime >= item.time) {
this.spawnedSpecialIndices.add(index);
mLogger.log(this.debugMode, 'MissionComp', ` 触发特殊刷怪: ${item.desc}`);
oops.message.dispatchEvent("SpawnSpecialMonster", {
uuid: item.uuid,
type: item.type,
level: item.level
});
}
});
}
private initMemoryPanel() {
if (!this.showMemoryPanel || !this.time_node) return;
let panel = this.time_node.getChildByName("mem_panel");
if (!panel) {
panel = new Node("mem_panel");
panel.parent = this.time_node;
panel.setPosition(0, -32, 0);
}
let label = panel.getComponent(Label);
if (!label) {
label = panel.addComponent(Label);
}
label.fontSize = 16;
label.lineHeight = 20;
this.memoryLabel = label;
}
private updateMemoryPanel(dt: number) {
if (!this.showMemoryPanel || !this.memoryLabel) return;
this.perfDtAcc += dt;
this.perfFrameCount += 1;
this.memoryRefreshTimer += dt;
if (this.memoryRefreshTimer < 0.5) return;
this.memoryRefreshTimer = 0;
let heroCount = 0;
ecs.query(this.heroViewMatcher).forEach(() => {
heroCount++;
});
let skillCount = 0;
ecs.query(this.skillViewMatcher).forEach(() => {
skillCount++;
});
const monPool = Monster.getPoolStats();
const skillPool = Skill.getPoolStats();
const perf = (globalThis as any).performance;
const heapBytes = perf && perf.memory ? perf.memory.usedJSHeapSize : 0;
let heapMB = heapBytes > 0 ? heapBytes / 1024 / 1024 : -1;
if (heapMB > 0 && this.heapBaseMB < 0) {
this.heapBaseMB = heapMB;
this.heapPeakMB = heapMB;
this.heapTrendBaseMB = heapMB;
this.heapTrendTimer = 0;
}
if (heapMB > this.heapPeakMB) {
this.heapPeakMB = heapMB;
}
this.heapTrendTimer += 0.5;
if (heapMB > 0 && this.heapTrendBaseMB > 0 && this.heapTrendTimer >= 10) {
const deltaMB = heapMB - this.heapTrendBaseMB;
this.heapTrendPerMinMB = (deltaMB / this.heapTrendTimer) * 60;
this.heapTrendBaseMB = heapMB;
this.heapTrendTimer = 0;
}
const heapText = heapMB > 0 ? heapMB.toFixed(1) : "N/A";
const heapDeltaText = this.heapBaseMB > 0 && heapMB > 0 ? (heapMB - this.heapBaseMB).toFixed(1) : "N/A";
const heapPeakText = this.heapPeakMB > 0 ? this.heapPeakMB.toFixed(1) : "N/A";
const avgDt = this.perfFrameCount > 0 ? this.perfDtAcc / this.perfFrameCount : 0;
const fps = avgDt > 0 ? 1 / avgDt : 0;
this.perfDtAcc = 0;
this.perfFrameCount = 0;
const text =
`Heap:${heapText}MB Δ:${heapDeltaText} Peak:${heapPeakText}\n` +
`Trend:${this.heapTrendPerMinMB.toFixed(2)}MB/min\n` +
`Perf dt:${(avgDt * 1000).toFixed(1)}ms fps:${fps.toFixed(1)}\n` +
`Ent H:${heroCount} S:${skillCount}\n` +
`Pool M:${monPool.total}(${monPool.paths}) K:${skillPool.total}(${skillPool.paths})`;
if (text === this.lastMemoryText) return;
this.lastMemoryText = text;
this.memoryLabel.string = text;
}
//奖励发放
@@ -197,18 +109,7 @@ export class MissionComp extends CCComp {
// 奖励发放
}
cal_gold_reward(data: any, type: MonType) {
const cost = MonsterCost[data.uuid] || 1;
const level = data.lv || 1;
let add_gold = calculateMonsterGold(data.uuid, level, type);
smc.updateGold(add_gold, false);
}
do_hero_dead(event:any,data:any){
}
do_ad(){
do_ad(){
if(this.ad_back()){
oops.message.dispatchEvent(GameEvent.AD_BACK_TRUE)
smc.vmdata.mission_data.refresh_count+=FightSet.MORE_RC
@@ -216,11 +117,8 @@ do_ad(){
oops.message.dispatchEvent(GameEvent.AD_BACK_FALSE)
}
}
ad_back(){
return true
}
@@ -298,7 +196,6 @@ do_ad(){
this.FightTime=FightSet.FiIGHT_TIME
this.rewards=[] // 改为数组,用于存储掉落物品列表
this.revive_times = 1; // 每次任务开始重置复活次数
this.spawnedSpecialIndices.clear(); // 重置特殊刷怪记录
this.lastTimeStr = "";
this.lastTimeSecond = -1;
this.memoryRefreshTimer = 0;
@@ -336,8 +233,82 @@ do_ad(){
Skill.clearPools();
}
/** 性能监控相关代码 */
private initMemoryPanel() {
if (!this.showMemoryPanel || !this.time_node) return;
let panel = this.time_node.getChildByName("mem_panel");
if (!panel) {
panel = new Node("mem_panel");
panel.parent = this.time_node;
panel.setPosition(0, -32, 0);
}
let label = panel.getComponent(Label);
if (!label) {
label = panel.addComponent(Label);
}
label.fontSize = 16;
label.lineHeight = 20;
this.memoryLabel = label;
}
private updateMemoryPanel(dt: number) {
if (!this.showMemoryPanel || !this.memoryLabel) return;
this.perfDtAcc += dt;
this.perfFrameCount += 1;
this.memoryRefreshTimer += dt;
if (this.memoryRefreshTimer < 0.5) return;
this.memoryRefreshTimer = 0;
let heroCount = 0;
ecs.query(this.heroViewMatcher).forEach(() => {
heroCount++;
});
let skillCount = 0;
ecs.query(this.skillViewMatcher).forEach(() => {
skillCount++;
});
const monPool = Monster.getPoolStats();
const skillPool = Skill.getPoolStats();
const perf = (globalThis as any).performance;
const heapBytes = perf && perf.memory ? perf.memory.usedJSHeapSize : 0;
let heapMB = heapBytes > 0 ? heapBytes / 1024 / 1024 : -1;
if (heapMB > 0 && this.heapBaseMB < 0) {
this.heapBaseMB = heapMB;
this.heapPeakMB = heapMB;
this.heapTrendBaseMB = heapMB;
this.heapTrendTimer = 0;
}
if (heapMB > this.heapPeakMB) {
this.heapPeakMB = heapMB;
}
this.heapTrendTimer += 0.5;
if (heapMB > 0 && this.heapTrendBaseMB > 0 && this.heapTrendTimer >= 10) {
const deltaMB = heapMB - this.heapTrendBaseMB;
this.heapTrendPerMinMB = (deltaMB / this.heapTrendTimer) * 60;
this.heapTrendBaseMB = heapMB;
this.heapTrendTimer = 0;
}
const heapText = heapMB > 0 ? heapMB.toFixed(1) : "N/A";
const heapDeltaText = this.heapBaseMB > 0 && heapMB > 0 ? (heapMB - this.heapBaseMB).toFixed(1) : "N/A";
const heapPeakText = this.heapPeakMB > 0 ? this.heapPeakMB.toFixed(1) : "N/A";
const avgDt = this.perfFrameCount > 0 ? this.perfDtAcc / this.perfFrameCount : 0;
const fps = avgDt > 0 ? 1 / avgDt : 0;
this.perfDtAcc = 0;
this.perfFrameCount = 0;
const text =
`Heap:${heapText}MB Δ:${heapDeltaText} Peak:${heapPeakText}\n` +
`Trend:${this.heapTrendPerMinMB.toFixed(2)}MB/min\n` +
`Perf dt:${(avgDt * 1000).toFixed(1)}ms fps:${fps.toFixed(1)}\n` +
`Ent H:${heroCount} S:${skillCount}\n` +
`Pool M:${monPool.total}(${monPool.paths}) K:${skillPool.total}(${skillPool.paths})`;
if (text === this.lastMemoryText) return;
this.lastMemoryText = text;
this.memoryLabel.string = text;
}
/** 视图层逻辑代码分离演示 */
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {

View File

@@ -7,11 +7,8 @@ import { MonStart } from "../common/config/heroSet";
import { smc } from "../common/SingletonModuleComp";
import { GameEvent } from "../common/config/GameEvent";
// 导入新的肉鸽配置
import { getCurrentWave, MonType, WaveConfig } from "./RogueConfig";
import { BuffConf } from "../common/config/SkillSet";
import { IndexSet, FacSet, BoxSet } from "../common/config/GameSet";
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { Attrs } from "../common/config/HeroAttrs";
import {BoxSet } from "../common/config/GameSet";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@@ -24,26 +21,18 @@ export class MissionMonCompComp extends CCComp {
// 刷怪队列 (主要用于特殊事件插队)
private MonQueue: Array<{
uuid: number,
position: number,
type: MonType,
level: number,
buffs: BuffConf[]
}> = [];
private spawnCount: number = 0; // 召唤计数器
/** 全局生成顺序计数器,用于层级管理 */
private globalSpawnOrder: number = 0;
/** 游戏进行时间(秒) */
private gameTime: number = 0;
/** 波次刷怪计时器 */
private waveTimer: number = 0;
/** 队列处理计时器 */
private queueTimer: number = 0;
onLoad(){
this.on(GameEvent.FightReady,this.fight_ready,this)
this.on(GameEvent.NewWave,this.fight_ready,this)
@@ -59,16 +48,11 @@ export class MissionMonCompComp extends CCComp {
private onSpawnSpecialMonster(event: string, args: any) {
if (!args) return;
mLogger.log(this.debugMode, 'MissionMonComp', `[MissionMonComp] 收到特殊刷怪指令:`, args);
// 插入队列
this.MonQueue.push({
uuid: args.uuid,
position: args.position !== undefined ? args.position : 2, // 默认中间
type: args.type,
level: args.level,
buffs: args.buffs || []
});
// 立即触发一次队列检查 (可选,让 update 尽快处理)
this.queueTimer = 1.0;
}
@@ -98,112 +82,28 @@ export class MissionMonCompComp extends CCComp {
// 累加游戏时间
this.gameTime += dt;
// 获取当前波次配置
const currentWave = getCurrentWave(this.gameTime);
// 1. 优先处理特殊怪队列
if (this.MonQueue.length > 0) {
this.queueTimer += dt;
// 队列出怪速度快于普通波次 (0.5秒一只)
if (this.queueTimer >= 0.5) {
this.spawnNextFromQueue();
this.queueTimer = 0;
}
}
// 2. 处理波次自然刷怪
this.waveTimer += dt;
if (this.waveTimer >= currentWave.spawnInterval) {
this.waveTimer = 0;
// 检查同屏数量限制
if (smc.vmdata.mission_data.mon_num < currentWave.maxActive) {
this.spawnWaveMonster(currentWave);
}
}
}
/**
* 从当前波次配置生成并生成怪物
*/
private spawnWaveMonster(wave: WaveConfig) {
if (!wave.weights || wave.weights.length === 0) return;
// 权重随机算法
const totalWeight = wave.weights.reduce((sum, item) => sum + item.weight, 0);
let random = Math.random() * totalWeight;
let selectedUuid = wave.weights[0].uuid;
let selectedType = wave.weights[0].type || MonType.NORMAL;
for (const item of wave.weights) {
random -= item.weight;
if (random <= 0) {
selectedUuid = item.uuid;
selectedType = item.type || MonType.NORMAL;
break;
}
}
// 随机位置 (0-4)
const position = Math.floor(Math.random() * 5);
// 等级随时间增长 (每分钟+1级)
const level = Math.floor(this.gameTime / 60) + 1;
this.addMonster(
selectedUuid,
position,
selectedType,
level,
[],
this.gameTime
);
this.spawnCount++;
}
/**
* 从队列中生成下一个怪物
*/
private spawnNextFromQueue() {
if (this.MonQueue.length === 0) return;
const monsterData = this.MonQueue.shift();
if (monsterData) {
this.addMonster(
monsterData.uuid,
monsterData.position,
monsterData.type,
monsterData.level,
monsterData.buffs,
this.gameTime
);
this.spawnCount++;
}
}
private addMonster(
uuid: number = 1001,
i: number = 0,
monType: number = 0,
lv: number = 1,
buffs: BuffConf[] = [],
gameTime: number = 0
) {
let mon = ecs.getEntity<Monster>(Monster);
let scale = -1;
const x = MonStart.START_X + Math.floor(i / 4) * MonStart.START_I;
let y = BoxSet.GAME_LINE;
let lane = 0;
let pos: Vec3 = v3(x, y, 0);
// 递增全局生成顺序 - 溢出保护
this.globalSpawnOrder = (this.globalSpawnOrder + 1) % 999;
// 生成怪物
mon.load(pos, scale, uuid, lv, monType, buffs, false, lane, this.globalSpawnOrder, gameTime);
mon.load(pos, scale, uuid, false);
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */

View File

@@ -1,347 +1 @@
/**
* 肉鸽模式配置脚本 - 增强版 (Wave System)
*
* 功能说明:
* - 采用 15 个小波次(每分钟 1 波)
* - 整合进 3 个大的节奏阶段:构筑期、磨合期、极限期
* - 废弃动态预算,使用确定性波次配置
*
* @author 游戏开发团队
* @version 3.0 波次重构版
* @date 2025-10-19
*/
import { HeroInfo } from "../common/config/heroSet";
import { mLogger } from "../common/Logger";
/**
* 怪物类型枚举
*/
export enum MonType {
NORMAL = 0, // 普通怪物
ELITE = 1, // 精英怪物
BOSS = 2 // Boss怪物
}
/**
* 怪物配置接口 (用于生成实例)
*/
export interface IMonsConfig {
uuid: number; // 怪物ID
type: MonType; // 怪物类型
level: number; // 等级
position?: number; // 位置(可选)
buffs?: any[]; // buff列表可选
}
/**
* 怪物属性接口
*/
export interface MonAttrs {
hp: number;
ap: number;
speed: number;
exp?: number;
gold?: number;
}
/**
* 成长类型枚举
*/
enum GrowthType {
EXPONENTIAL = 1.15, // 指数级 - HP
LINEAR = 1.05, // 线性 - AP
LOGARITHMIC = 0.3 // 对数级 - Speed
}
/**
* 刷怪权重接口
*/
export interface SpawnWeight {
uuid: number;
weight: number;
type?: MonType; // 默认为 NORMAL
}
/**
* 波次配置接口
*/
export interface WaveConfig {
waveId: number; // 波次ID (1-15)
name: string; // 波次名称
duration: number; // 持续时间 (秒)通常为60
spawnInterval: number; // 刷怪间隔 (秒)
maxActive: number; // 同屏最大怪物数
weights: SpawnWeight[]; // 怪物权重池
}
// 怪物ID映射 (方便阅读)
const MON_IDS = {
WARRIOR: 5201, // 战士
ASSASSIN: 5301, // 斥候
TANK: 5401, // 卫士
ARCHER: 5501, // 射手
BOMBER: 5601, // 自爆兵
SUMMONER: 5602, // 召唤师
HEALER: 5603, // 祭司
TOTEM: 5604, // 图腾师
BOSS: 5701 // 首领
};
/**
* 全局波次配置表 (15波)
*/
export const RogueWaves: WaveConfig[] = [
// --- 第一阶段:构筑期 (0-5min) ---
{
waveId: 1, name: "热身", duration: 60, spawnInterval: 2.0, maxActive: 5,
weights: [{ uuid: MON_IDS.WARRIOR, weight: 100 }]
},
{
waveId: 2, name: "加速", duration: 60, spawnInterval: 1.8, maxActive: 6,
weights: [
{ uuid: MON_IDS.WARRIOR, weight: 80 },
{ uuid: MON_IDS.ASSASSIN, weight: 20 }
]
},
{
waveId: 3, name: "堆叠", duration: 60, spawnInterval: 1.6, maxActive: 7,
weights: [
{ uuid: MON_IDS.WARRIOR, weight: 60 },
{ uuid: MON_IDS.ASSASSIN, weight: 40 }
]
},
{
waveId: 4, name: "硬度测试", duration: 60, spawnInterval: 1.5, maxActive: 8,
weights: [
{ uuid: MON_IDS.WARRIOR, weight: 50 },
{ uuid: MON_IDS.ASSASSIN, weight: 30 },
{ uuid: MON_IDS.TANK, weight: 20 }
]
},
{
waveId: 5, name: "精英首秀", duration: 60, spawnInterval: 1.5, maxActive: 8,
weights: [
{ uuid: MON_IDS.WARRIOR, weight: 40 },
{ uuid: MON_IDS.ASSASSIN, weight: 40 },
{ uuid: MON_IDS.TANK, weight: 20 }
// 注意第5分钟会触发固定事件刷精英怪这里只配普通怪
]
},
// --- 第二阶段:磨合期 (5-10min) ---
{
waveId: 6, name: "远程威胁", duration: 60, spawnInterval: 1.4, maxActive: 10,
weights: [
{ uuid: MON_IDS.TANK, weight: 30 },
{ uuid: MON_IDS.ARCHER, weight: 40 },
{ uuid: MON_IDS.WARRIOR, weight: 30 }
]
},
{
waveId: 7, name: "铁桶阵", duration: 60, spawnInterval: 1.3, maxActive: 10,
weights: [
{ uuid: MON_IDS.TANK, weight: 50 },
{ uuid: MON_IDS.ARCHER, weight: 50 }
]
},
{
waveId: 8, name: "续航干扰", duration: 60, spawnInterval: 1.2, maxActive: 12,
weights: [
{ uuid: MON_IDS.WARRIOR, weight: 30 },
{ uuid: MON_IDS.TANK, weight: 20 },
{ uuid: MON_IDS.ARCHER, weight: 30 },
{ uuid: MON_IDS.HEALER, weight: 20 }
]
},
{
waveId: 9, name: "走位测试", duration: 60, spawnInterval: 1.2, maxActive: 12,
weights: [
{ uuid: MON_IDS.WARRIOR, weight: 40 },
{ uuid: MON_IDS.BOMBER, weight: 30 }, // 自爆兵
{ uuid: MON_IDS.ARCHER, weight: 30 }
]
},
{
waveId: 10, name: "中场Boss", duration: 60, spawnInterval: 5.0, maxActive: 3,
// Boss战期间只刷少量护卫Boss由事件触发
weights: [
{ uuid: MON_IDS.TANK, weight: 100 }
]
},
// --- 第三阶段:极限期 (10-15min) ---
{
waveId: 11, name: "混乱开端", duration: 60, spawnInterval: 1.0, maxActive: 15,
weights: [
{ uuid: MON_IDS.SUMMONER, weight: 20 },
{ uuid: MON_IDS.TOTEM, weight: 20 },
{ uuid: MON_IDS.WARRIOR, weight: 30 },
{ uuid: MON_IDS.ARCHER, weight: 30 }
]
},
{
waveId: 12, name: "全家桶", duration: 60, spawnInterval: 0.9, maxActive: 18,
weights: [
{ uuid: MON_IDS.WARRIOR, weight: 15 },
{ uuid: MON_IDS.ASSASSIN, weight: 15 },
{ uuid: MON_IDS.TANK, weight: 15 },
{ uuid: MON_IDS.ARCHER, weight: 15 },
{ uuid: MON_IDS.BOMBER, weight: 15 },
{ uuid: MON_IDS.HEALER, weight: 10 },
{ uuid: MON_IDS.SUMMONER, weight: 15 }
]
},
{
waveId: 13, name: "精英小队", duration: 60, spawnInterval: 1.0, maxActive: 15,
weights: [
{ uuid: MON_IDS.TANK, weight: 40 },
{ uuid: MON_IDS.ARCHER, weight: 40 },
{ uuid: MON_IDS.WARRIOR, weight: 20, type: MonType.ELITE } // 尝试混入精英
]
},
{
waveId: 14, name: "绝地求生", duration: 60, spawnInterval: 0.6, maxActive: 20,
weights: [
{ uuid: MON_IDS.ASSASSIN, weight: 50 },
{ uuid: MON_IDS.BOMBER, weight: 50 }
]
},
{
waveId: 15, name: "终局", duration: 60, spawnInterval: 3.0, maxActive: 5,
// 最终Boss战只刷少量精英护卫
weights: [
{ uuid: MON_IDS.TANK, weight: 100, type: MonType.ELITE }
]
}
];
// 精英怪和Boss刷新时间配置 (时间单位: 秒)
// 注意:这里的时间点应与波次结束/开始对应
export const SpecialMonsterSchedule = [
{ time: 4 * 60 + 50, uuid: MON_IDS.WARRIOR, type: MonType.ELITE, level: 5, desc: "5分钟前夕: 精英战士" },
{ time: 9 * 60 + 55, uuid: MON_IDS.BOSS, type: MonType.BOSS, level: 15, desc: "10分钟: 兽人首领" },
{ time: 14 * 60 + 55, uuid: MON_IDS.BOSS, type: MonType.BOSS, level: 30, desc: "15分钟: 最终Boss" }
];
/**
* 获取当前时间的波次配置
* @param timeInSeconds 游戏时间 (秒)
*/
export function getCurrentWave(timeInSeconds: number): WaveConfig {
const waveIndex = Math.min(Math.floor(timeInSeconds / 60), 14);
return RogueWaves[waveIndex];
}
/**
* 怪物消耗点数配置 (用于经验/金币计算)
*/
export const MonsterCost: Record<number, number> = {
5201: 1, // 兽人战士 (Warrior)
5301: 3, // 兽人斥候 (Assassin)
5401: 5, // 兽人卫士 (Tank)
5501: 4, // 兽人射手 (Remote)
5601: 10, // 兽人自爆兵 (Mechanic)
5602: 8, // 兽人召唤师
5603: 6, // 兽人祭司 (Healer)
5604: 6, // 兽人图腾师
5701: 50, // 兽人首领 (Elite/Boss)
};
/**
* 计算波次因子
* @param stage 当前波次
* @param timeInSeconds 游戏进行时间(秒)
* @returns 波次因子 (0-1之间15分钟时达到最大)
*/
function calculateWaveFactor(stage: number, timeInSeconds: number = 0): number {
const MAX_GAME_TIME = 15 * 60; // 15分钟 = 900秒
const effectiveTime = timeInSeconds || (stage * 60);
const factor = Math.min(effectiveTime / MAX_GAME_TIME, 1.0);
return factor;
}
/**
* 应用成长公式到基础属性
*/
function applyGrowthFormula(baseStat: number, waveFactor: number, growthType: GrowthType): number {
// 基础倍率15分钟成长约 21 倍 (1 + 1.0 * 20)
const TIME_SCALING = 20;
const growthMultiplier = Math.pow(1 + waveFactor * TIME_SCALING, growthType);
return Math.floor(baseStat * growthMultiplier);
}
/**
* 获取怪物动态成长属性
* @param stage 当前波次 (这里复用为等级或忽略)
* @param uuid 怪物ID
* @param monType 怪物类型
* @param timeInSeconds 游戏进行时间(秒)
* @returns 怪物属性
*/
export function getMonAttr(stage: number, uuid: number, monType: MonType = MonType.NORMAL, timeInSeconds: number = 0): MonAttrs {
const baseMonster = HeroInfo[uuid];
if (!baseMonster) {
mLogger.warn(true, 'RogueConfig', `[RogueConfig] 未找到怪物ID: ${uuid}`);
return { hp: 100, ap: 10, speed: 100 };
}
// 计算波次因子
const waveFactor = calculateWaveFactor(0, timeInSeconds);
// 动态质量系数:初始 1.5倍 -> 15分钟 6.0倍
// 大幅降低初始强度(原固定5.0),随时间线性增强
const qualityRatio = 1.5 + (4.5 * waveFactor);
// 根据怪物类型应用额外的倍率
let typeMultiplier = 1.0;
if (monType === MonType.ELITE) {
typeMultiplier = 2.0; // 精英怪2倍属性
} else if (monType === MonType.BOSS) {
typeMultiplier = 5.0; // Boss 5倍属性
}
// 应用不同的成长类型 (应用质量系数)
const hp = applyGrowthFormula(baseMonster.hp, waveFactor, GrowthType.EXPONENTIAL) * typeMultiplier * qualityRatio;
const ap = applyGrowthFormula(baseMonster.ap, waveFactor, GrowthType.LINEAR) * typeMultiplier * qualityRatio;
const speed = applyGrowthFormula(baseMonster.speed, waveFactor, GrowthType.LOGARITHMIC);
return {
hp: Math.floor(hp),
ap: Math.floor(ap),
speed: Math.floor(speed)
};
}
/**
* 无限等级经验配置
*/
export function getLevelExp(level: number): number {
const baseExp = 100;
const growthFactor = 1.2;
return Math.floor(baseExp * Math.pow(growthFactor, level - 1));
}
/**
* 计算怪物掉落金币
*/
export function calculateMonsterGold(uuid: number, level: number, type: MonType): number {
const cost = MonsterCost[uuid] || 1;
let danger_ratio = 1 + cost * 0.1;
let type_ratio = 1;
if(type == MonType.BOSS) type_ratio = 10;
else if(type == MonType.ELITE) type_ratio = 3;
const baseGold = 10;
let gold = Math.floor((baseGold * type_ratio * danger_ratio + level) * 8);
return gold;
}
/**
* 计算怪物经验值
*/
export function calculateMonsterExp(uuid: number, level: number): number {
const cost = MonsterCost[uuid] || 1;
return Math.max(1, Math.floor(cost * 1.0 * Math.pow(1.15, level - 1) * 8));
}