2 Commits

Author SHA1 Message Date
68b9c1924b 刷怪 未完成 2025-10-28 23:51:15 +08:00
166200af73 刷怪 未完成 2025-10-28 23:48:04 +08:00
4 changed files with 289 additions and 254 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +1,12 @@
/** /**
* 英雄升级经验配置表 * 英雄升级经验配置表
* ExpConf[lv-1] 返回从当前等级到下一级所需的经验值 * ExpConf[lv] 返回从当前等级到下一级所需的经验值
* 1-30级:初始值20,每级提升约20% * 1-30级:初始值20,每级提升约20%
* 31-100级:每级在前一级基础上+1000 * 31-100级:每级在前一级基础上+1000
*/ */
export const ExpConf: number[] = [ export const ExpConf: number[] = [
// Lv1-10 // Lv1-10
20, 24, 29, 35, 42, 50, 60, 72, 86, 103, 0,20, 24, 29, 35, 42, 50, 60, 72, 86, 103,
// Lv11-20 // Lv11-20
124, 149, 179, 215, 258, 310, 372, 446, 535, 642, 124, 149, 179, 215, 258, 310, 372, 446, 535, 642,
// Lv21-30 // Lv21-30
@@ -27,3 +27,95 @@ export const ExpConf: number[] = [
65000, 66000, 67000, 68000, 69000, 70000, 71000, 72000, 73000, 74000 65000, 66000, 67000, 68000, 69000, 70000, 71000, 72000, 73000, 74000
]; ];
/**
* 怪物击杀经验配置表
* MonExp[lv] 返回该等级怪物提供的经验值
*
* 设计规则:
* - 1-10级: 5个怪物 = ExpConf[lv-1],即 MonExp[lv] = ExpConf[lv-1] / 5
* - 11-20级: 10个怪物 = ExpConf[lv-1],即 MonExp[lv] = ExpConf[lv-1] / 10
* - 21-30级: 15个怪物 = ExpConf[lv-1],即 MonExp[lv] = ExpConf[lv-1] / 15
* - 31级及以上: 固定为30级的经验值即 MonExp[lv] = MonExp[30]
*
* 索引说明MonExp[1] 表示1级怪物的经验值
*/
export const MonExp: number[] = [
// Lv0-10
0, 4, 5, 6, 7, 8, 10, 12, 14, 17, 21,
// Lv11-20
12, 15, 18, 22, 26, 31, 37, 45, 54, 64,
// Lv21-30
51, 62, 74, 89, 106, 128, 153, 184, 221, 267,
// Lv31-40
267, 267, 267, 267, 267, 267, 267, 267, 267, 267,
// Lv41-50
267, 267, 267, 267, 267, 267, 267, 267, 267, 267,
// Lv51-60
267, 267, 267, 267, 267, 267, 267, 267, 267, 267,
// Lv61-70
267, 267, 267, 267, 267, 267, 267, 267, 267, 267,
// Lv71-80
267, 267, 267, 267, 267, 267, 267, 267, 267, 267,
// Lv81-90
267, 267, 267, 267, 267, 267, 267, 267, 267, 267,
// Lv91-100
267, 267, 267, 267, 267, 267, 267, 267, 267, 267
];
/**
* 等级属性成长系数配置
* 用于计算角色/怪物升级时各属性的增长值
*
* 计算公式:
* - 当前等级属性 = 基础属性 × (1 + 等级 × 成长系数)
* 例如10级角色HP = 基础HP × (1 + 10 × 0.08) = 基础HP × 1.8
*/
export const LevelAttrGrowthConfig = {
/** 生命值成长系数每级增长8% */
hp: 0.08,
/** 魔法值成长系数每级增长6% */
mp: 0.06,
/** 攻击力成长系数每级增长5% */
ap: 0.05,
/** 防御力成长系数每级增长4% */
def: 0.04
};
/**
* 根据等级计算属性值
* @param baseValue 基础属性值
* @param level 当前等级
* @param growthRate 成长系数
* @returns 计算后的属性值(向下取整)
*/
export function calculateAttrByLevel(baseValue: number, level: number, growthRate: number): number {
return Math.floor(baseValue * (1 + level * growthRate));
}
/**
* 根据等级计算所有属性
* @param baseHP 基础生命值
* @param baseMP 基础魔法值
* @param baseAP 基础攻击力
* @param baseDEF 基础防御力
* @param level 当前等级
* @returns 包含所有计算后属性的对象
*/
export function calculateAllAttrsByLevel(
baseHP: number,
baseMP: number,
baseAP: number,
baseDEF: number,
level: number
): { hp: number; mp: number; ap: number; def: number } {
return {
hp: calculateAttrByLevel(baseHP, level, LevelAttrGrowthConfig.hp),
mp: calculateAttrByLevel(baseMP, level, LevelAttrGrowthConfig.mp),
ap: calculateAttrByLevel(baseAP, level, LevelAttrGrowthConfig.ap),
def: calculateAttrByLevel(baseDEF, level, LevelAttrGrowthConfig.def)
};
}

View File

@@ -7,11 +7,8 @@ import { smc } from "../common/SingletonModuleComp";
import { GameEvent } from "../common/config/GameEvent"; import { GameEvent } from "../common/config/GameEvent";
// 导入肉鸽配置 // 导入肉鸽配置
import { import {
getStageMonsterConfigs,
MonsterType, MonsterType,
getStageType,
EventType, EventType,
getRandomEvent
} from "./RogueConfig"; } from "./RogueConfig";
import { MonModelComp } from "../hero/MonModelComp"; import { MonModelComp } from "../hero/MonModelComp";

View File

@@ -11,301 +11,247 @@
* @date 2025-10-19 * @date 2025-10-19
*/ */
import { isModuleNamespaceObject } from "util/types";
import { getMonList, HeroInfo } from "../common/config/heroSet"; import { getMonList, HeroInfo } from "../common/config/heroSet";
import { Attrs } from "../common/config/SkillSet"; import { NATIVE } from "cc/env";
import { BuffConf } from "../common/config/SkillSet";
// 精英怪物配置表 // 精英怪物配置表
export const EliteMonsterList = [ export const EliteMons = [ 5201, 5202, 5203,
5201, // 兽人战士
5202, // 兽人刺客
5203, // 兽人护卫
// 可以添加更多精英怪物UUID // 可以添加更多精英怪物UUID
]; ];
// Boss怪物配置表 // Boss怪物配置表
export const BossMonsterList = [ export const BossMons = [ 5201, 5202,
5201, // 兽人战士
5202, // 兽人刺客
// 可以添加更多Boss怪物UUID // 可以添加更多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 MonsterType { export enum MonType {
NORMAL = "normal", // 普通怪物 NORMAL = 0, // 普通怪物
ELITE = "elite", // 精英怪物 ELITE = 1, // 精英怪物
BOSS = "boss" // Boss怪物 BOSS = 2 // Boss怪物
} }
/** /**
* 关卡类型枚举 * 关卡类型枚举
*/ */
export enum StageType { export const EliteStage:any =(wave:number) => {
NORMAL = "normal", // 普通关卡 if(wave%5 == 0) return true
ELITE = "elite", // 精英关卡 return false
BOSS = "boss", // Boss关卡 }
EVENT = "event" // 事件关卡 export const BossStage:any =(wave:number) => {
if(wave%10 == 0) return true
return false
} }
/** /**
* 随机事件类型枚举 * 随机事件类型枚举
*/ */
export enum EventType { export enum EventType {
TREASURE = "treasure", // 额外奖励 TREASURE = 1, // 额外奖励
TRAP = "trap", // 陷阱伤害 TRAP =2, // 陷阱伤害
BUFF = "buff", // 临时增益效果 BUFF = 3, // 临时增益效果
DEBUFF = "debuff" // 临时减益效果 DEBUFF = 4 // 临时减益效果
} }
/** /**
* 关卡配置规则 - 增强版,支持怪物数量和强度随关卡递增 * 关卡生怪物相关配置
*/ */
export const StageConfigRules = { export const StageRule = {
// 普通关卡 MonsNum: 5, // 关卡中默认怪物数量
[StageType.NORMAL]: { /** 额外怪物出现概率在固定5个怪物基础上有概率多刷1个 */
description: "普通关卡", extraMonsterRate: 0.3, // 30%概率出现第6个怪物
monsters: [ /** 事件怪物出现概率5个怪物中有1个替换为事件怪 */
{ type: MonsterType.NORMAL, count: 3, minCount: 2, maxCount: 6 } // 普通怪物数量随关卡递增 eventMonsterRate: 0.25, // 25%概率出现事件怪物
] /** 特殊属性怪物出现概率5个怪物中有怪物携带特殊属性 */
}, specialAttributeRate: 0.4, // 40%概率出现特殊属性怪物
/** 特殊属性怪物数量范围 */
// 精英关卡 specialAttributeCount: { min: 1, max: 2 } // 出现时1-2个怪物会有特殊属性
[StageType.ELITE]: {
description: "精英关卡",
monsters: [
{ type: MonsterType.ELITE, count: 2, minCount: 1, maxCount: 4 }, // 精英怪物
{ type: MonsterType.NORMAL, count: 3, minCount: 2, maxCount: 5 } // 普通怪物
]
},
// Boss关卡
[StageType.BOSS]: {
description: "Boss关卡",
monsters: [
{ type: MonsterType.BOSS, count: 1, minCount: 1, maxCount: 1 }, // 1个Boss怪物
{ type: MonsterType.ELITE, count: 2, minCount: 1, maxCount: 3 }, // 精英怪物
{ type: MonsterType.NORMAL, count: 2, minCount: 1, maxCount: 4 } // 普通怪物
]
},
// 事件关卡
[StageType.EVENT]: {
description: "事件关卡",
monsters: [
{ type: MonsterType.NORMAL, count: 2, minCount: 1, maxCount: 4 } // 少量普通怪物
]
}
}; };
/** interface IMonsConfig {
* 随机事件配置 /** 怪物波次 */
*/ uuid: number; // 怪物ID
export const EventConfig = { /** 怪物数量 */
[EventType.TREASURE]: { buff: BuffConf[]; //附加属性
description: "宝箱事件", /** 怪物等级 */
probability: 0.3, // 30%概率触发 level: number; // 怪物等级
effect: "获得额外奖励" /** 是否为精英怪物 */
}, isElite?: boolean; // 是否为精英怪物
[EventType.TRAP]: { /** 是否为Boss怪物 */
description: "陷阱事件", isBoss?: boolean; // 是否为Boss怪物
probability: 0.25, // 25%概率触发
effect: "受到一定伤害"
},
[EventType.BUFF]: {
description: "增益事件",
probability: 0.25, // 25%概率触发
effect: "获得临时增益效果"
},
[EventType.DEBUFF]: {
description: "减益事件",
probability: 0.2, // 20%概率触发
effect: "受到临时减益效果"
}
};
/**
* 根据关卡号和等级判断关卡类型
* @param stageNumber 关卡号从1开始
* @param level 等级1-5
* @returns 关卡类型
*/
export function getStageType(stageNumber: number, level: number = 1): StageType {
// 每隔5关设置特殊事件关卡
if (stageNumber % 5 === 0 && level === 3) {
return StageType.EVENT;
} }
// 第10关的特殊规则
if (stageNumber % 10 === 0) { export enum MonAttrSet{
if (level === 5) { HP_MAX=1.1,
return StageType.BOSS; // 第10关第5级为Boss关 AP=1.05,
} else if (level === 4) { MP=1.1,
return StageType.ELITE; // 第10关第4级为精英关 DEF=1.05,
} else { MDEF=1.05,
return StageType.NORMAL; // 第10关1-3级为普通关 MAP=1.05,
}
}
// 1-9关的规则
else {
if (level === 5) {
return StageType.ELITE; // 1-9关第5级为精英关
} else {
return StageType.NORMAL; // 1-9关1-4级为普通关
}
} }
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 stageNumber 关卡号 * @param wave 当前波次
* @param baseCount 基础数量 * @returns IMonsConfig数组
* @param minCount 最小数量
* @param maxCount 最大数量
* @returns 实际怪物数量
*/ */
export function calculateMonsterCount(stageNumber: number, baseCount: number, minCount: number, maxCount: number): number { export function getStageMonsterConfigs(wave: number): IMonsConfig[] {
// 随关卡递增每5关增加1个怪物最多不超过最大数量 const monsterConfigs: IMonsConfig[] = [];
const increment = Math.floor(stageNumber / 5);
let count = baseCount + increment;
// 确保在最小和最大数量之间 // 确定基础怪物数量
count = Math.max(minCount, Math.min(maxCount, count)); let baseMonsterCount = StageRule.MonsNum;
return count; // 判断是否为Boss波次
} const isBossWave = BossStage(wave);
/** // 判断是否为精英波次
* 计算怪物强度倍率,随关卡进度递增 const isEliteWave = EliteStage(wave);
* @param stageNumber 关卡号
* @param level 等级
* @returns 强度倍率
*/
export function calculateMonsterStrengthMultiplier(stageNumber: number, level: number): number {
// 基础倍率基于关卡号和等级
const stageMultiplier = 1 + (stageNumber - 1) * 0.1; // 每关增加10%
const levelMultiplier = 1 + (level - 1) * 0.05; // 每级增加5%
return stageMultiplier * levelMultiplier; // 如果是Boss波次增加一个Boss怪物
} if (isBossWave) {
// 从Boss怪物列表中随机选择一个
/** const bossUUID = BossMons[Math.floor(Math.random() * BossMons.length)] || 5201;
* 生成关卡配置 monsterConfigs.push({
* @param stageNumber 关卡号从1开始 uuid: bossUUID,
* @param level 等级1-5 buff: [],
* @returns MonsterType数组格式 level: wave, // Boss等级等于波次
*/ isBoss: true
export function generateStageConfig(stageNumber: number, level: number = 1): MonsterType[] {
const stageType = getStageType(stageNumber, level);
const rule = StageConfigRules[stageType];
const monsterArray: MonsterType[] = [];
// 根据配置生成怪物类型数组
rule.monsters.forEach(monsterGroup => {
// 计算实际怪物数量
const actualCount = calculateMonsterCount(
stageNumber,
monsterGroup.count,
monsterGroup.minCount,
monsterGroup.maxCount
);
for (let i = 0; i < actualCount; i++) {
monsterArray.push(monsterGroup.type);
}
}); });
return monsterArray; // Boss波次减少普通怪物数量
baseMonsterCount = Math.max(1, baseMonsterCount - 2);
} }
/** // 如果是精英波次,增加精英怪物
* 根据怪物类型获取对应配置表中的怪物UUID数组 if (isEliteWave) {
* @param monsterType 怪物类型 // 添加1-2个精英怪物
* @returns 怪物UUID数组 const eliteCount = isBossWave ? 1 : Math.floor(Math.random() * 2) + 1;
*/ for (let i = 0; i < eliteCount; i++) {
export function getMonsterUUIDsByType(monsterType: MonsterType): number[] { const eliteUUID = EliteMons[Math.floor(Math.random() * EliteMons.length)] || 5201;
switch (monsterType) { monsterConfigs.push({
case MonsterType.NORMAL: uuid: eliteUUID,
// 普通怪物使用原有的getMonList方法 buff: [],
return getMonList(); level: wave, // 精英等级等于波次
case MonsterType.ELITE: isElite: true
// 精英怪物使用精英配置表
return EliteMonsterList;
case MonsterType.BOSS:
// Boss怪物使用Boss配置表
return BossMonsterList;
default:
return [];
}
}
/**
* 获取当前关卡对应的所有怪物UUID数组
* @param stageNumber 关卡号
* @param level 等级1-5
* @returns 怪物UUID数组按关卡配置顺序排列
*/
export function getStageMonsterUUIDs(stageNumber: number, level: number = 1): number[] {
const monsterTypes = generateStageConfig(stageNumber, level);
const monsterUUIDs: number[] = [];
monsterTypes.forEach(monsterType => {
const availableUUIDs = getMonsterUUIDsByType(monsterType);
if (availableUUIDs.length > 0) {
// 随机选择一个该类型的怪物
const randomUUID = availableUUIDs[Math.floor(Math.random() * availableUUIDs.length)];
monsterUUIDs.push(randomUUID);
}
}); });
return monsterUUIDs;
} }
/** // 精英波次减少普通怪物数量
* 获取关卡怪物配置包含UUID和强度信息 baseMonsterCount = Math.max(1, baseMonsterCount - eliteCount);
* @param stageNumber 关卡号 }
* @param level 等级1-5
* @returns 怪物配置数组
*/
export function getStageMonsterConfigs(stageNumber: number, level: number = 1) {
const monsterTypes = generateStageConfig(stageNumber, level);
const monsterConfigs = [];
// 计算强度倍率 // 添加普通怪物
const strengthMultiplier = calculateMonsterStrengthMultiplier(stageNumber, level); const remainingCount = baseMonsterCount;
for (let i = 0; i < remainingCount; i++) {
monsterTypes.forEach((monsterType, index) => { // 从普通怪物列表中随机选择一个
const availableUUIDs = getMonsterUUIDsByType(monsterType); const normalMonsters = getMonList();
if (availableUUIDs.length > 0) { const normalUUID = normalMonsters.length > 0
const randomUUID = availableUUIDs[Math.floor(Math.random() * availableUUIDs.length)]; ? normalMonsters[Math.floor(Math.random() * normalMonsters.length)]
: 5201;
monsterConfigs.push({ monsterConfigs.push({
uuid: randomUUID, uuid: normalUUID,
type: monsterType, buff: [],
stageNumber: stageNumber, level: wave // 普通怪物等级等于波次
level: level,
strengthMultiplier: strengthMultiplier // 强度倍率
}); });
} }
// 判断是否生成额外怪物
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; return monsterConfigs;
} }
/** /**
* 随机决定是否触发事件 * 特殊属性类型枚举
* @returns 事件类型或null
*/ */
export function getRandomEvent(): EventType | null { export enum SpecialAttribute {
const random = Math.random(); NONE = 0, // 无特殊属性
let cumulativeProbability = 0; FAST = 1, // 快速移动
STRONG = 2, // 强力攻击
for (const eventType in EventConfig) { TANKY = 3, // 高生命值
cumulativeProbability += EventConfig[eventType].probability; REGENERATE = 4, // 生命恢复
if (random <= cumulativeProbability) { SHIELD = 5, // 护盾
return eventType as EventType; EXPLOSIVE = 6, // 爆炸伤害(死亡时)
} VAMPIRE = 7 // 吸血
} }
return null; // 不触发事件 /**
* 特殊属性配置
*/
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 }
} }
};