feat(怪物生成): 添加全局配置系统并优化怪物生成逻辑
引入全局配置接口 IRogueGlobalConfig 用于集中管理怪物生成参数 添加配置获取和更新方法 getRogueConfig/updateRogueConfig 修改生成逻辑使用配置参数控制间隔、数量限制和预算计算 增加单次生成数量限制和同屏怪物数量限制
This commit is contained in:
@@ -6,7 +6,7 @@ import { MonStart } from "../common/config/heroSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
// 导入肉鸽配置
|
||||
import { getStageMonConfigs, MonType, generateMonstersFromBudget } from "./RogueConfig";
|
||||
import { getStageMonConfigs, MonType, generateMonstersFromBudget, getRogueConfig } from "./RogueConfig";
|
||||
import { BuffConf } from "../common/config/SkillSet";
|
||||
import { IndexSet, FacSet } from "../common/config/GameSet";
|
||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
@@ -64,30 +64,34 @@ export class MissionMonCompComp extends CCComp {
|
||||
|
||||
// 累加游戏时间
|
||||
this.gameTime += dt;
|
||||
const config = getRogueConfig();
|
||||
|
||||
// ==========================================
|
||||
// 新增:每秒执行一次刷怪逻辑 (Threat Budget)
|
||||
// ==========================================
|
||||
this.spawnLogicTimer += dt;
|
||||
if (this.spawnLogicTimer >= 1.0) {
|
||||
if (this.spawnLogicTimer >= config.spawnLogicInterval) {
|
||||
this.spawnLogicTimer = 0;
|
||||
|
||||
// 获取英雄血量比例
|
||||
const hpRatio = this.getHeroHpRatio();
|
||||
|
||||
// 生成怪物
|
||||
const newMonsters = generateMonstersFromBudget(this.gameTime, hpRatio);
|
||||
|
||||
// 添加到队列
|
||||
newMonsters.forEach(mon => {
|
||||
this.addToStageSpawnQueue(
|
||||
mon.uuid,
|
||||
mon.position !== undefined ? mon.position : 0,
|
||||
mon.type,
|
||||
mon.level,
|
||||
mon.buffs || []
|
||||
);
|
||||
});
|
||||
// 检查最大怪物数量限制
|
||||
if (smc.vmdata.mission_data.mon_num < config.maxMonsterCount) {
|
||||
// 获取英雄血量比例
|
||||
const hpRatio = this.getHeroHpRatio();
|
||||
|
||||
// 生成怪物
|
||||
const newMonsters = generateMonstersFromBudget(this.gameTime, hpRatio);
|
||||
|
||||
// 添加到队列
|
||||
newMonsters.forEach(mon => {
|
||||
this.addToStageSpawnQueue(
|
||||
mon.uuid,
|
||||
mon.position !== undefined ? mon.position : 0,
|
||||
mon.type,
|
||||
mon.level,
|
||||
mon.buffs || []
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 处理随机事件
|
||||
@@ -98,7 +102,7 @@ export class MissionMonCompComp extends CCComp {
|
||||
this.spawnTimer += dt;
|
||||
|
||||
// 正常召唤间隔
|
||||
if (this.spawnTimer >= this.spawnInterval) {
|
||||
if (this.spawnTimer >= config.spawnInterval) {
|
||||
this.spawnNextMonster();
|
||||
this.spawnTimer = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user