feat(关卡): 将Boss刷新机制改为基于时间轴
将Boss刷新从固定周期改为基于时间轴配置,支持在特定时间点生成多个Boss
This commit is contained in:
@@ -7,7 +7,7 @@ import { HeroInfo, MonStart } from "../common/config/heroSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import {BoxSet } from "../common/config/GameSet";
|
||||
import { BossList, BossSpawnCd, MonList, MonType, SpawnBaseCd, SpawnMinCd, SpawnPowerBias, SpawnStageReduce, StageBossGrow, StageDuration, StageGrow, UpType } from "./RogueConfig";
|
||||
import { BossList, BossSpawnTimeline, MonList, MonType, SpawnBaseCd, SpawnMinCd, SpawnPowerBias, SpawnStageReduce, StageBossGrow, StageDuration, StageGrow, UpType } from "./RogueConfig";
|
||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
import { MoveComp } from "../hero/MoveComp";
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -36,8 +36,7 @@ export class MissionMonCompComp extends CCComp {
|
||||
private waveTimer: number = 0;
|
||||
/** 插队刷怪处理计时器 */
|
||||
private queueTimer: number = 0;
|
||||
/** Boss 刷新计时器 */
|
||||
private bossTimer: number = 0;
|
||||
private nextBossSpawnIndex: number = 0;
|
||||
onLoad(){
|
||||
// 关卡准备、切换波次时重置刷怪状态
|
||||
this.on(GameEvent.FightReady,this.fight_ready,this)
|
||||
@@ -72,7 +71,7 @@ export class MissionMonCompComp extends CCComp {
|
||||
this.gameTime = 0
|
||||
this.waveTimer = 0
|
||||
this.queueTimer = 0
|
||||
this.bossTimer = 0
|
||||
this.nextBossSpawnIndex = 0
|
||||
this.MonQueue = []
|
||||
this.spawnCount = 0
|
||||
|
||||
@@ -84,15 +83,14 @@ export class MissionMonCompComp extends CCComp {
|
||||
if(!smc.mission.play) return
|
||||
if(smc.mission.pause) return
|
||||
if(smc.mission.stop_mon_action) return;
|
||||
if(smc.mission.stop_spawn_mon) return;
|
||||
if(!smc.mission.in_fight) return;
|
||||
|
||||
// 计时推进:所有“按时间驱动”的曲线都依赖 gameTime
|
||||
this.gameTime += dt;
|
||||
// 刷怪优先级:特殊队列 > 普通怪 > Boss(都满足条件时同帧可连续执行)
|
||||
this.updateBossSpawn();
|
||||
if(smc.mission.stop_spawn_mon) return;
|
||||
this.updateSpecialQueue(dt);
|
||||
this.updateNormalSpawn(dt);
|
||||
this.updateBossSpawn(dt);
|
||||
|
||||
}
|
||||
|
||||
@@ -124,15 +122,17 @@ export class MissionMonCompComp extends CCComp {
|
||||
this.spawnCount += 1;
|
||||
}
|
||||
|
||||
private updateBossSpawn(dt: number) {
|
||||
this.bossTimer += dt;
|
||||
// Boss 按固定周期出现,不受普通怪 CD 影响
|
||||
if (this.bossTimer < BossSpawnCd) return;
|
||||
this.bossTimer = 0;
|
||||
const uuid = this.getRandomBossUuid();
|
||||
const upType = this.getRandomUpType();
|
||||
this.addMonster(uuid, this.spawnCount, true, upType);
|
||||
this.spawnCount += 1;
|
||||
private updateBossSpawn() {
|
||||
while (
|
||||
this.nextBossSpawnIndex < BossSpawnTimeline.length &&
|
||||
this.gameTime >= BossSpawnTimeline[this.nextBossSpawnIndex]
|
||||
) {
|
||||
const uuid = this.getRandomBossUuid();
|
||||
const upType = this.getRandomUpType();
|
||||
this.addMonster(uuid, this.spawnCount, true, upType);
|
||||
this.spawnCount += 1;
|
||||
this.nextBossSpawnIndex += 1;
|
||||
}
|
||||
}
|
||||
|
||||
private getCurrentStage(): number {
|
||||
|
||||
@@ -33,6 +33,6 @@ export const StageDuration = 30
|
||||
export const SpawnBaseCd = 1.6
|
||||
export const SpawnMinCd = 0.5
|
||||
export const SpawnStageReduce = 0.08
|
||||
export const BossSpawnCd = 90
|
||||
export const BossSpawnTimeline = [60, 120, 180, 240, 300]
|
||||
export const SpawnPowerBias = 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user