diff --git a/assets/script/game/map/RogueConfig.ts b/assets/script/game/map/RogueConfig.ts index 4445c4e3..d7dae377 100644 --- a/assets/script/game/map/RogueConfig.ts +++ b/assets/script/game/map/RogueConfig.ts @@ -18,11 +18,11 @@ import { BuffConf } from "../common/config/SkillSet"; // 精英怪物配置表 -export const EliteMonsterList = [ 5201, 5202, 5203, +export const EliteMons = [ 5201, 5202, 5203, // 可以添加更多精英怪物UUID ]; // Boss怪物配置表 -export const BossMonsterList = [ 5201, 5202, +export const BossMons = [ 5201, 5202, // 可以添加更多Boss怪物UUID ]; export enum IMons{ @@ -39,7 +39,7 @@ export const Mons={ /** * 怪物类型枚举 */ -export enum MonsterType { +export enum MonType { NORMAL = 0, // 普通怪物 ELITE = 1, // 精英怪物 BOSS = 2 // Boss怪物 @@ -73,13 +73,10 @@ export const StageRule = { MonsNum: 5, // 关卡中默认怪物数量 /** 额外怪物出现概率(在固定5个怪物基础上,有概率多刷1个) */ extraMonsterRate: 0.3, // 30%概率出现第6个怪物 - /** 事件怪物出现概率(5个怪物中有1个替换为事件怪) */ eventMonsterRate: 0.25, // 25%概率出现事件怪物 - /** 特殊属性怪物出现概率(5个怪物中有怪物携带特殊属性) */ specialAttributeRate: 0.4, // 40%概率出现特殊属性怪物 - /** 特殊属性怪物数量范围 */ specialAttributeCount: { min: 1, max: 2 } // 出现时,1-2个怪物会有特殊属性 }; @@ -89,6 +86,12 @@ interface IMonsConfig { uuid: number; // 怪物ID /** 怪物数量 */ buff: BuffConf[]; //附加属性 + /** 怪物等级 */ + level: number; // 怪物等级 + /** 是否为精英怪物 */ + isElite?: boolean; // 是否为精英怪物 + /** 是否为Boss怪物 */ + isBoss?: boolean; // 是否为Boss怪物 } @@ -112,6 +115,89 @@ export const getMonAttr=(lv:number,uuid:number)=>{ return {hp:hp,mp:mp,ap:ap,map:map,def:def,mdef:mdef} } +/** + * 根据波次生成怪物配置 + * @param wave 当前波次 + * @returns IMonsConfig数组 + */ +export function getStageMonsterConfigs(wave: number): IMonsConfig[] { + const monsterConfigs: IMonsConfig[] = []; + + // 确定基础怪物数量 + let baseMonsterCount = StageRule.MonsNum; + + // 判断是否为Boss波次 + const isBossWave = BossStage(wave); + + // 判断是否为精英波次 + const isEliteWave = EliteStage(wave); + + // 如果是Boss波次,增加一个Boss怪物 + if (isBossWave) { + // 从Boss怪物列表中随机选择一个 + const bossUUID = BossMons[Math.floor(Math.random() * BossMons.length)] || 5201; + monsterConfigs.push({ + uuid: bossUUID, + buff: [], + level: wave, // Boss等级等于波次 + isBoss: true + }); + + // Boss波次减少普通怪物数量 + baseMonsterCount = Math.max(1, baseMonsterCount - 2); + } + + // 如果是精英波次,增加精英怪物 + if (isEliteWave) { + // 添加1-2个精英怪物 + const eliteCount = isBossWave ? 1 : Math.floor(Math.random() * 2) + 1; + for (let i = 0; i < eliteCount; i++) { + const eliteUUID = EliteMons[Math.floor(Math.random() * EliteMons.length)] || 5201; + monsterConfigs.push({ + uuid: eliteUUID, + buff: [], + level: wave, // 精英等级等于波次 + isElite: true + }); + } + + // 精英波次减少普通怪物数量 + baseMonsterCount = Math.max(1, baseMonsterCount - eliteCount); + } + + // 添加普通怪物 + const remainingCount = baseMonsterCount; + for (let i = 0; i < remainingCount; i++) { + // 从普通怪物列表中随机选择一个 + const normalMonsters = getMonList(); + const normalUUID = normalMonsters.length > 0 + ? normalMonsters[Math.floor(Math.random() * normalMonsters.length)] + : 5201; + + monsterConfigs.push({ + uuid: normalUUID, + buff: [], + level: wave // 普通怪物等级等于波次 + }); + } + + // 判断是否生成额外怪物 + if (Math.random() < StageRule.extraMonsterRate) { + const normalMonsters = getMonList(); + const extraUUID = normalMonsters.length > 0 + ? normalMonsters[Math.floor(Math.random() * normalMonsters.length)] + : 5201; + + monsterConfigs.push({ + uuid: extraUUID, + buff: [], + level: wave + }); + } + + return monsterConfigs; +} + /** * 特殊属性类型枚举