refactor(game): 简化怪物生成逻辑并移除肉鸽配置
- 移除 RogueConfig 及相关动态成长系统 - 简化 Monster.load() 方法参数,直接使用 heroSet 配置 - 移除 MissionMonComp 中的波次生成逻辑和特殊队列 - 清理 MissionComp 中与肉鸽相关的特殊刷怪检查 - 调整 heroSet 配置,移除 buff 字段并统一技能 - 更新技能配置,增加更多攻击特效
This commit is contained in:
@@ -7,11 +7,8 @@ import { MonStart } from "../common/config/heroSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
// 导入新的肉鸽配置
|
||||
import { getCurrentWave, MonType, WaveConfig } from "./RogueConfig";
|
||||
import { BuffConf } from "../common/config/SkillSet";
|
||||
import { IndexSet, FacSet, BoxSet } from "../common/config/GameSet";
|
||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
import { Attrs } from "../common/config/HeroAttrs";
|
||||
import {BoxSet } from "../common/config/GameSet";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@@ -24,26 +21,18 @@ export class MissionMonCompComp extends CCComp {
|
||||
// 刷怪队列 (主要用于特殊事件插队)
|
||||
private MonQueue: Array<{
|
||||
uuid: number,
|
||||
position: number,
|
||||
type: MonType,
|
||||
level: number,
|
||||
buffs: BuffConf[]
|
||||
}> = [];
|
||||
|
||||
private spawnCount: number = 0; // 召唤计数器
|
||||
|
||||
/** 全局生成顺序计数器,用于层级管理 */
|
||||
private globalSpawnOrder: number = 0;
|
||||
|
||||
/** 游戏进行时间(秒) */
|
||||
private gameTime: number = 0;
|
||||
|
||||
/** 波次刷怪计时器 */
|
||||
private waveTimer: number = 0;
|
||||
|
||||
/** 队列处理计时器 */
|
||||
private queueTimer: number = 0;
|
||||
|
||||
onLoad(){
|
||||
this.on(GameEvent.FightReady,this.fight_ready,this)
|
||||
this.on(GameEvent.NewWave,this.fight_ready,this)
|
||||
@@ -59,16 +48,11 @@ export class MissionMonCompComp extends CCComp {
|
||||
private onSpawnSpecialMonster(event: string, args: any) {
|
||||
if (!args) return;
|
||||
mLogger.log(this.debugMode, 'MissionMonComp', `[MissionMonComp] 收到特殊刷怪指令:`, args);
|
||||
|
||||
// 插入队列
|
||||
this.MonQueue.push({
|
||||
uuid: args.uuid,
|
||||
position: args.position !== undefined ? args.position : 2, // 默认中间
|
||||
type: args.type,
|
||||
level: args.level,
|
||||
buffs: args.buffs || []
|
||||
});
|
||||
|
||||
// 立即触发一次队列检查 (可选,让 update 尽快处理)
|
||||
this.queueTimer = 1.0;
|
||||
}
|
||||
@@ -98,112 +82,28 @@ export class MissionMonCompComp extends CCComp {
|
||||
// 累加游戏时间
|
||||
this.gameTime += dt;
|
||||
|
||||
// 获取当前波次配置
|
||||
const currentWave = getCurrentWave(this.gameTime);
|
||||
|
||||
// 1. 优先处理特殊怪队列
|
||||
if (this.MonQueue.length > 0) {
|
||||
this.queueTimer += dt;
|
||||
// 队列出怪速度快于普通波次 (0.5秒一只)
|
||||
if (this.queueTimer >= 0.5) {
|
||||
this.spawnNextFromQueue();
|
||||
this.queueTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 处理波次自然刷怪
|
||||
this.waveTimer += dt;
|
||||
if (this.waveTimer >= currentWave.spawnInterval) {
|
||||
this.waveTimer = 0;
|
||||
|
||||
// 检查同屏数量限制
|
||||
if (smc.vmdata.mission_data.mon_num < currentWave.maxActive) {
|
||||
this.spawnWaveMonster(currentWave);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从当前波次配置生成并生成怪物
|
||||
*/
|
||||
private spawnWaveMonster(wave: WaveConfig) {
|
||||
if (!wave.weights || wave.weights.length === 0) return;
|
||||
|
||||
// 权重随机算法
|
||||
const totalWeight = wave.weights.reduce((sum, item) => sum + item.weight, 0);
|
||||
let random = Math.random() * totalWeight;
|
||||
let selectedUuid = wave.weights[0].uuid;
|
||||
let selectedType = wave.weights[0].type || MonType.NORMAL;
|
||||
|
||||
for (const item of wave.weights) {
|
||||
random -= item.weight;
|
||||
if (random <= 0) {
|
||||
selectedUuid = item.uuid;
|
||||
selectedType = item.type || MonType.NORMAL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 随机位置 (0-4)
|
||||
const position = Math.floor(Math.random() * 5);
|
||||
|
||||
// 等级随时间增长 (每分钟+1级)
|
||||
const level = Math.floor(this.gameTime / 60) + 1;
|
||||
|
||||
this.addMonster(
|
||||
selectedUuid,
|
||||
position,
|
||||
selectedType,
|
||||
level,
|
||||
[],
|
||||
this.gameTime
|
||||
);
|
||||
|
||||
this.spawnCount++;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从队列中生成下一个怪物
|
||||
*/
|
||||
private spawnNextFromQueue() {
|
||||
if (this.MonQueue.length === 0) return;
|
||||
|
||||
const monsterData = this.MonQueue.shift();
|
||||
if (monsterData) {
|
||||
this.addMonster(
|
||||
monsterData.uuid,
|
||||
monsterData.position,
|
||||
monsterData.type,
|
||||
monsterData.level,
|
||||
monsterData.buffs,
|
||||
this.gameTime
|
||||
);
|
||||
this.spawnCount++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private addMonster(
|
||||
uuid: number = 1001,
|
||||
i: number = 0,
|
||||
monType: number = 0,
|
||||
lv: number = 1,
|
||||
buffs: BuffConf[] = [],
|
||||
gameTime: number = 0
|
||||
) {
|
||||
let mon = ecs.getEntity<Monster>(Monster);
|
||||
let scale = -1;
|
||||
|
||||
const x = MonStart.START_X + Math.floor(i / 4) * MonStart.START_I;
|
||||
let y = BoxSet.GAME_LINE;
|
||||
let lane = 0;
|
||||
|
||||
|
||||
let pos: Vec3 = v3(x, y, 0);
|
||||
|
||||
// 递增全局生成顺序 - 溢出保护
|
||||
this.globalSpawnOrder = (this.globalSpawnOrder + 1) % 999;
|
||||
|
||||
// 生成怪物
|
||||
mon.load(pos, scale, uuid, lv, monType, buffs, false, lane, this.globalSpawnOrder, gameTime);
|
||||
mon.load(pos, scale, uuid, false);
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
|
||||
Reference in New Issue
Block a user