Files
heros/assets/script/game/map/RogueConfig.ts
2025-10-28 23:51:15 +08:00

258 lines
7.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 肉鸽模式配置脚本 - 增强版
*
* 功能说明:
* - 提供基础的刷怪配置:刷什么怪,刷多少怪
* - 支持程序化关卡生成逻辑,每一关的怪物组合、数量和强度应随关卡进度递增而变化
* - 支持随机事件系统
*
* @author 游戏开发团队
* @version 2.0 增强版
* @date 2025-10-19
*/
import { isModuleNamespaceObject } from "util/types";
import { getMonList, HeroInfo } from "../common/config/heroSet";
import { NATIVE } from "cc/env";
import { BuffConf } from "../common/config/SkillSet";
// 精英怪物配置表
export const EliteMons = [ 5201, 5202, 5203,
// 可以添加更多精英怪物UUID
];
// Boss怪物配置表
export const BossMons = [ 5201, 5202,
// 可以添加更多Boss怪物UUID
];
export enum IMons{
ORC=1,
NATIVE=2,
ELF=3,
}
export const Mons={
[IMons.ORC]:[5201,5202],
[IMons.NATIVE]:[5201,5202],
[IMons.ELF]:[5201,5202]
}
/**
* 怪物类型枚举
*/
export enum MonType {
NORMAL = 0, // 普通怪物
ELITE = 1, // 精英怪物
BOSS = 2 // Boss怪物
}
/**
* 关卡类型枚举
*/
export const EliteStage:any =(wave:number) => {
if(wave%5 == 0) return true
return false
}
export const BossStage:any =(wave:number) => {
if(wave%10 == 0) return true
return false
}
/**
* 随机事件类型枚举
*/
export enum EventType {
TREASURE = 1, // 额外奖励
TRAP =2, // 陷阱伤害
BUFF = 3, // 临时增益效果
DEBUFF = 4 // 临时减益效果
}
/**
* 关卡生怪物相关配置
*/
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个怪物会有特殊属性
};
interface IMonsConfig {
/** 怪物波次 */
uuid: number; // 怪物ID
/** 怪物数量 */
buff: BuffConf[]; //附加属性
/** 怪物等级 */
level: number; // 怪物等级
/** 是否为精英怪物 */
isElite?: boolean; // 是否为精英怪物
/** 是否为Boss怪物 */
isBoss?: boolean; // 是否为Boss怪物
}
export enum MonAttrSet{
HP_MAX=1.1,
AP=1.05,
MP=1.1,
DEF=1.05,
MDEF=1.05,
MAP=1.05,
}
export const getMonAttr=(lv:number,uuid:number)=>{
let mon=HeroInfo[uuid]
let hp=mon.hp*lv*MonAttrSet.HP_MAX
let mp=mon.mp*lv*MonAttrSet.MP
let ap=mon.ap*lv*MonAttrSet.AP
let map=mon.map*lv*MonAttrSet.MAP
let def=mon.def*lv*MonAttrSet.DEF
let mdef=mon.mdef*lv*MonAttrSet.MDEF
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;
}
/**
* 特殊属性类型枚举
*/
export enum SpecialAttribute {
NONE = 0, // 无特殊属性
FAST = 1, // 快速移动
STRONG = 2, // 强力攻击
TANKY = 3, // 高生命值
REGENERATE = 4, // 生命恢复
SHIELD = 5, // 护盾
EXPLOSIVE = 6, // 爆炸伤害(死亡时)
VAMPIRE = 7 // 吸血
}
/**
* 特殊属性配置
*/
export const SpecialAttributeConfig = {
[SpecialAttribute.FAST]: {
name: "疾行",
description: "移动速度提升50%",
effect: { speedMultiplier: 1.5 }
},
[SpecialAttribute.STRONG]: {
name: "强力",
description: "攻击力提升30%",
effect: { attackMultiplier: 1.3 }
},
[SpecialAttribute.TANKY]: {
name: "坦克",
description: "生命值提升50%",
effect: { hpMultiplier: 1.5 }
},
[SpecialAttribute.REGENERATE]: {
name: "再生",
description: "每秒恢复最大生命值2%",
effect: { regenRate: 0.02 }
},
[SpecialAttribute.SHIELD]: {
name: "护盾",
description: "拥有相当于30%最大生命值的护盾",
effect: { shieldRatio: 0.3 }
},
[SpecialAttribute.EXPLOSIVE]: {
name: "爆炸",
description: "死亡时对周围造成范围伤害",
effect: { explosionDamageRatio: 0.5 }
},
[SpecialAttribute.VAMPIRE]: {
name: "吸血",
description: "攻击时恢复造成伤害20%的生命值",
effect: { vampireRatio: 0.2 }
}
};