刷怪完成
This commit is contained in:
@@ -10,7 +10,14 @@ import { smc } from "../common/SingletonModuleComp";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
// 导入肉鸽配置
|
||||
import { getRogueWaveConfig, RogueConfig, RogueWaveType, AffixCountConfig, MonsterAffixConfig } from "./RogueConfig";
|
||||
import {
|
||||
generateStageConfig,
|
||||
getStageMonsterConfigs,
|
||||
getStageAllMultipliers,
|
||||
MonsterType,
|
||||
StageType,
|
||||
getStageType
|
||||
} from "./RogueConfig";
|
||||
import { MonModelComp } from "../hero/MonModelComp";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -18,16 +25,14 @@ const { ccclass, property } = _decorator;
|
||||
/** 视图层对象 */
|
||||
@ccclass('MissionMonCompComp')
|
||||
@ecs.register('MissionMonComp', false)
|
||||
export class MissionMonCompComp extends CCComp { // 添加刷怪队列 - 扩展支持词条
|
||||
export class MissionMonCompComp extends CCComp { // 添加刷怪队列 - 使用新的RogueConfig格式
|
||||
private monsterQueue: Array<{
|
||||
uuid: number,
|
||||
position: number,
|
||||
isBoss: boolean,
|
||||
type: MonsterType,
|
||||
level: number,
|
||||
affixes?: any[],
|
||||
buffData?: any[], // 使用BuffAttr格式的buff数据
|
||||
rogueHp?: number, // 肉鸽固定血量
|
||||
rogueAttack?: number // 肉鸽固定攻击力
|
||||
enhancement?: any, // 增强属性配置
|
||||
stageMultipliers?: any // 关卡倍数配置
|
||||
}> = [];
|
||||
private isSpawning: boolean = false;// 是否正在生成怪物
|
||||
private spawnInterval: number = 0.1; // 每个怪物生成间隔时间
|
||||
@@ -49,7 +54,7 @@ export class MissionMonCompComp extends CCComp { // 添加刷怪队列 - 扩
|
||||
}
|
||||
|
||||
fight_ready(){
|
||||
console.log("[MissionMonComp]:fight_ready")
|
||||
// console.log("[MissionMonComp]:fight_ready")
|
||||
this.do_mon_wave()
|
||||
}
|
||||
|
||||
@@ -68,7 +73,7 @@ export class MissionMonCompComp extends CCComp { // 添加刷怪队列 - 扩
|
||||
this.isPausing = false;
|
||||
this.spawnCount = 0;
|
||||
this.spawnTimer = 0;
|
||||
console.log("[MissionMonComp]: 暂停结束,继续召唤怪物");
|
||||
// console.log("[MissionMonComp]: 暂停结束,继续召唤怪物");
|
||||
}
|
||||
return; // 暂停期间不召唤怪物
|
||||
}
|
||||
@@ -82,7 +87,7 @@ export class MissionMonCompComp extends CCComp { // 添加刷怪队列 - 扩
|
||||
if (this.spawnCount >= 5) {
|
||||
this.isPausing = true;
|
||||
this.spawnTimer = 0; // 重置计时器用于暂停计时
|
||||
console.log("[MissionMonComp]: 已召唤5只怪物,开始暂停5秒");
|
||||
// console.log("[MissionMonComp]: 已召唤5只怪物,开始暂停5秒");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,125 +95,101 @@ export class MissionMonCompComp extends CCComp { // 添加刷怪队列 - 扩
|
||||
|
||||
|
||||
do_mon_wave(){
|
||||
console.log("[MissionMonComp]:怪物登场,当前波次 :",smc.vmdata.mission_data.current_wave)
|
||||
// console.log("[MissionMonComp]:怪物登场,当前关卡 :",smc.vmdata.mission_data.current_wave)
|
||||
// 重置召唤相关状态
|
||||
this.spawnCount = 0;
|
||||
this.isPausing = false;
|
||||
this.spawnTimer = 0;
|
||||
|
||||
const currentWave = smc.vmdata.mission_data.current_wave;
|
||||
// 使用肉鸽模式配置
|
||||
const rogueWaveConfig = getRogueWaveConfig(currentWave);
|
||||
console.log(`[MissionMonComp]:肉鸽模式第${currentWave}波配置:`, rogueWaveConfig.description);
|
||||
this.generateRogueMonstersFromConfig(rogueWaveConfig);
|
||||
const currentStage = smc.vmdata.mission_data.current_wave;
|
||||
// 使用新的肉鸽关卡配置
|
||||
const stageType = getStageType(currentStage);
|
||||
const monsterConfigs = getStageMonsterConfigs(currentStage);
|
||||
console.log(`[MissionMonComp]:第${currentStage}关 - ${stageType}类型,怪物数量: ${monsterConfigs.length}`);
|
||||
this.generateMonstersFromStageConfig(monsterConfigs);
|
||||
}
|
||||
|
||||
|
||||
// 根据肉鸽配置生成怪物(肉鸽模式)
|
||||
private generateRogueMonstersFromConfig(rogueWaveConfig: any) {
|
||||
const { monsters, waveType } = rogueWaveConfig;
|
||||
const currentWave = smc.vmdata.mission_data.current_wave;
|
||||
const monsterLevel = RogueConfig.getMonsterLevel(currentWave);
|
||||
smc.vmdata.mission_data.mon_num=monsters.reduce((total: number, group: any) => total + group.count, 0);
|
||||
// 固定9波模式,所有波次都是战斗波次
|
||||
console.log(`[MissionMonComp]:第${currentWave}波 - ${waveType}战斗波次`);
|
||||
// 根据新的关卡配置生成怪物
|
||||
private generateMonstersFromStageConfig(monsterConfigs: any[]) {
|
||||
const currentStage = smc.vmdata.mission_data.current_wave;
|
||||
|
||||
if (!monsters || monsters.length === 0) {
|
||||
console.warn(`[MissionMonComp]:肉鸽波次配置中没有怪物信息`);
|
||||
// 设置怪物总数
|
||||
smc.vmdata.mission_data.mon_num = monsterConfigs.length;
|
||||
|
||||
if (!monsterConfigs || monsterConfigs.length === 0) {
|
||||
console.warn(`[MissionMonComp]:关卡${currentStage}配置中没有怪物信息`);
|
||||
return;
|
||||
}
|
||||
|
||||
monsters.forEach((monsterGroup: any) => {
|
||||
const { uuid, count, affixes, enhancedStats, buffData, isBoss, rogueHp, rogueAttack } = monsterGroup;
|
||||
// 为每个怪物配置生成怪物
|
||||
monsterConfigs.forEach((monsterConfig: any, index: number) => {
|
||||
const { uuid, type, enhancement, stageMultipliers } = monsterConfig;
|
||||
|
||||
// 为每个怪物组生成指定数量的怪物
|
||||
for (let i = 0; i < count; i++) {
|
||||
// 位置循环使用 (0-9),如果怪物数量超过10个位置,则循环使用
|
||||
const position = i % 5;
|
||||
this.addToSpawnQueueWithAffixes(
|
||||
uuid,
|
||||
position,
|
||||
isBoss || false,
|
||||
monsterLevel,
|
||||
affixes,
|
||||
buffData, // 现在传递buffData而不是enhancedStats和specialEffects
|
||||
rogueHp, // 传递固定血量
|
||||
rogueAttack // 传递固定攻击力
|
||||
);
|
||||
}
|
||||
// 位置循环使用 (0-4)
|
||||
const position = index % 5;
|
||||
|
||||
this.addToStageSpawnQueue(
|
||||
uuid,
|
||||
position,
|
||||
type,
|
||||
1, // 默认等级1
|
||||
enhancement,
|
||||
stageMultipliers
|
||||
);
|
||||
});
|
||||
|
||||
const totalMonsters = monsters.reduce((total: number, group: any) => total + group.count, 0);
|
||||
console.log(`[MissionMonComp]:肉鸽模式本波次将生成 ${totalMonsters} 只怪物,等级: ${monsterLevel}`);
|
||||
console.log(`[MissionMonComp]:关卡${currentStage}将生成 ${monsterConfigs.length} 只怪物`);
|
||||
|
||||
// 输出词条信息
|
||||
monsters.forEach((monsterGroup: any) => {
|
||||
if (monsterGroup.buffData && monsterGroup.buffData.length > 0) {
|
||||
console.log(`[MissionMonComp]:怪物 ${monsterGroup.uuid} 拥有词条:`, monsterGroup.buffData);
|
||||
// 输出词条名称
|
||||
monsterGroup.buffData.forEach((buff: any) => {
|
||||
const config = MonsterAffixConfig[buff.buff_type];
|
||||
if (config) {
|
||||
console.log(`[MissionMonComp]: - ${config.name}: ${config.description}`);
|
||||
}
|
||||
});
|
||||
// 输出增强属性信息
|
||||
monsterConfigs.forEach((monsterConfig: any) => {
|
||||
if (monsterConfig.enhancement && monsterConfig.enhancement.buffList.length > 0) {
|
||||
console.log(`[MissionMonComp]:怪物 ${monsterConfig.uuid} (${monsterConfig.type}) 拥有增强属性:`,
|
||||
monsterConfig.enhancement.buffList.map((buff: any) => `${buff.name}:+${buff.value}`));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 新增:添加到刷怪队列 - 增加level参数(普通模式)
|
||||
private addToSpawnQueue(uuid: number, position: number, isBoss: boolean = false, level: number = 1) {
|
||||
this.monsterQueue.push({
|
||||
uuid: uuid,
|
||||
position: position,
|
||||
isBoss: isBoss,
|
||||
level: level
|
||||
});
|
||||
}
|
||||
|
||||
// 新增:添加到刷怪队列 - 支持词条(肉鸽模式)
|
||||
private addToSpawnQueueWithAffixes(
|
||||
// 添加到关卡刷怪队列 - 使用新的配置格式
|
||||
private addToStageSpawnQueue(
|
||||
uuid: number,
|
||||
position: number,
|
||||
isBoss: boolean = false,
|
||||
type: MonsterType,
|
||||
level: number = 1,
|
||||
affixes?: any[],
|
||||
buffData?: any[],
|
||||
rogueHp?: number,
|
||||
rogueAttack?: number
|
||||
enhancement?: any,
|
||||
stageMultipliers?: any
|
||||
) {
|
||||
this.monsterQueue.push({
|
||||
uuid: uuid,
|
||||
position: position,
|
||||
isBoss: isBoss,
|
||||
type: type,
|
||||
level: level,
|
||||
affixes: affixes,
|
||||
buffData: buffData,
|
||||
rogueHp: rogueHp,
|
||||
rogueAttack: rogueAttack
|
||||
enhancement: enhancement,
|
||||
stageMultipliers: stageMultipliers
|
||||
});
|
||||
}
|
||||
|
||||
// 新增:从队列中生成下一个怪物 - 传递词条参数
|
||||
// 从队列中生成下一个怪物 - 使用新的配置格式
|
||||
private spawnNextMonster() {
|
||||
if (this.monsterQueue.length === 0) return;
|
||||
|
||||
const monsterData = this.monsterQueue.shift();
|
||||
if (monsterData) {
|
||||
const isBoss = monsterData.type === MonsterType.BOSS;
|
||||
|
||||
this.addMonster(
|
||||
monsterData.uuid,
|
||||
monsterData.position,
|
||||
monsterData.isBoss,
|
||||
isBoss,
|
||||
false,
|
||||
monsterData.level,
|
||||
monsterData.buffData,
|
||||
monsterData.rogueHp,
|
||||
monsterData.rogueAttack
|
||||
monsterData.enhancement,
|
||||
monsterData.stageMultipliers
|
||||
);
|
||||
|
||||
// 增加召唤计数
|
||||
this.spawnCount++;
|
||||
console.log(`[MissionMonComp]: 召唤第${this.spawnCount}只怪物,剩余队列: ${this.monsterQueue.length}`);
|
||||
console.log(`[MissionMonComp]: 召唤第${this.spawnCount}只${monsterData.type}怪物,剩余队列: ${this.monsterQueue.length}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,25 +199,25 @@ export class MissionMonCompComp extends CCComp { // 添加刷怪队列 - 扩
|
||||
is_boss: boolean = false,
|
||||
is_call: boolean = false,
|
||||
lv: number = 1,
|
||||
buffData?: any[],
|
||||
rogueHp?: number,
|
||||
rogueAttack?: number
|
||||
enhancement?: any,
|
||||
stageMultipliers?: any
|
||||
) {
|
||||
let mon = ecs.getEntity<Monster>(Monster);
|
||||
let scale = -1;
|
||||
let pos: Vec3 = v3(MonSet[i].pos);
|
||||
|
||||
// 生成怪物,传递词条buff数据和肉鸽固定数值
|
||||
mon.load(pos, scale, uuid, is_boss, is_call, lv, buffData, rogueHp, rogueAttack);
|
||||
// 生成怪物,传递增强属性和关卡倍数
|
||||
mon.load(pos, scale, uuid, is_boss, is_call, lv, enhancement, stageMultipliers);
|
||||
|
||||
// 如果有词条buff数据,记录到控制台
|
||||
if (buffData && buffData.length > 0) {
|
||||
console.log(`[MissionMonComp]: 怪物 ${uuid} 获得肉鸽词条Buff:`, buffData);
|
||||
// 如果有增强属性,记录到控制台
|
||||
if (enhancement && enhancement.buffList && enhancement.buffList.length > 0) {
|
||||
console.log(`[MissionMonComp]: 怪物 ${uuid} 获得增强属性:`,
|
||||
enhancement.buffList.map((buff: any) => `${buff.name}:+${buff.value}`));
|
||||
}
|
||||
|
||||
// 如果有肉鸽固定数值,记录到控制台
|
||||
if (rogueHp !== undefined && rogueAttack !== undefined) {
|
||||
console.log(`[MissionMonComp]: 怪物 ${uuid} 使用肉鸽固定数值 - HP: ${rogueHp}, 攻击: ${rogueAttack}`);
|
||||
// 如果有关卡倍数,记录到控制台
|
||||
if (stageMultipliers) {
|
||||
console.log(`[MissionMonComp]: 怪物 ${uuid} 关卡倍数 - HP: x${stageMultipliers.hp.toFixed(2)}, 攻击: x${stageMultipliers.attack.toFixed(2)}`);
|
||||
}
|
||||
}
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
|
||||
Reference in New Issue
Block a user