feat(关卡): 实现基于波次的怪物生成系统

- 将时间轴刷怪改为波次制,每波生成固定数量普通怪
- 每若干波生成一个Boss,Boss波次可配置
- 在界面时间显示前添加当前波次信息
- 添加新波次开始时的事件通知机制
- 调整卡片预制件的Y坐标以适应新布局
This commit is contained in:
walkpan
2026-03-26 21:19:12 +08:00
parent 3963a8f3ba
commit 4fdb424bc4
5 changed files with 2696 additions and 2114 deletions

View File

@@ -60,6 +60,7 @@ export class MissionComp extends CCComp {
private heapTrendTimer: number = 0;
private heapTrendBaseMB: number = -1;
private monsterCountSyncTimer: number = 0;
private currentWave: number = 0;
private readonly heroViewMatcher = ecs.allOf(HeroViewComp);
private readonly skillViewMatcher = ecs.allOf(SkillView);
private readonly heroAttrsMatcher = ecs.allOf(HeroAttrsComp);
@@ -72,6 +73,7 @@ export class MissionComp extends CCComp {
// this.on(GameEvent.HeroDead,this.do_hero_dead,this)
// this.on(GameEvent.FightEnd,this.fight_end,this)
this.on(GameEvent.MissionEnd,this.mission_end,this)
this.on(GameEvent.NewWave,this.onNewWave,this)
this.on(GameEvent.DO_AD_BACK,this.do_ad,this)
this.removeMemoryPanel()
}
@@ -94,7 +96,8 @@ export class MissionComp extends CCComp {
this.lastTimeSecond = remainSecond;
let m = Math.floor(remainSecond / 60);
let s = remainSecond % 60;
let str = `${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`;
const wave = Math.max(1, this.currentWave || smc.vmdata.mission_data.level || 1);
let str = `W${wave.toString().padStart(2, '0')} ${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`;
if(str != this.lastTimeStr){
this.time_node.getChildByName("time").getComponent(Label).string = str;
this.lastTimeStr = str;
@@ -125,10 +128,9 @@ export class MissionComp extends CCComp {
this.unscheduleAllCallbacks();
// 确保清理上一局的残留实体
this.cleanComponents();
oops.message.dispatchEvent(GameEvent.FightReady)
this.node.active=true
this.data_init()
oops.message.dispatchEvent(GameEvent.FightReady)
let loading=this.node.parent.getChildByName("loading")
loading.active=true
this.scheduleOnce(()=>{
@@ -197,6 +199,7 @@ export class MissionComp extends CCComp {
smc.vmdata.mission_data.mon_num=0
smc.vmdata.mission_data.level=0
smc.vmdata.mission_data.mon_max = Math.max(1, Math.floor(this.maxMonsterCount))
this.currentWave = 0;
this.FightTime=FightSet.FiIGHT_TIME
this.rewards=[] // 改为数组,用于存储掉落物品列表
this.revive_times = 1; // 每次任务开始重置复活次数
@@ -221,6 +224,15 @@ export class MissionComp extends CCComp {
// mLogger.log(this.debugMode, 'MissionComp', "局内数据初始化",smc.vmdata.mission_data)
}
private onNewWave(event: string, data: any) {
const wave = Number(data?.wave ?? 0);
if (wave <= 0) return;
this.currentWave = wave;
smc.vmdata.mission_data.level = wave;
this.lastTimeSecond = -1;
this.update_time();
}
private getMonsterThresholds(): { max: number; resume: number } {
const max = Math.max(1, Math.floor(this.maxMonsterCount));
const resume = Math.min(max - 1, Math.max(0, Math.floor(this.resumeMonsterCount)));