添加 缓冲倒计时
This commit is contained in:
@@ -18,9 +18,7 @@ const { ccclass, property } = _decorator;
|
||||
/** 视图层对象 */
|
||||
@ccclass('MissionMonCompComp')
|
||||
@ecs.register('MissionMonComp', false)
|
||||
export class MissionMonCompComp extends CCComp {
|
||||
timer:Timer=new Timer(1)
|
||||
// 添加刷怪队列 - 扩展支持词条
|
||||
export class MissionMonCompComp extends CCComp { // 添加刷怪队列 - 扩展支持词条
|
||||
private monsterQueue: Array<{
|
||||
uuid: number,
|
||||
position: number,
|
||||
@@ -34,43 +32,20 @@ export class MissionMonCompComp extends CCComp {
|
||||
private isSpawning: boolean = false;// 是否正在生成怪物
|
||||
private spawnInterval: number = 0.1; // 每个怪物生成间隔时间
|
||||
private spawnTimer: number = 0; // 生成计时器
|
||||
private is_fight:boolean = false;
|
||||
|
||||
|
||||
|
||||
onLoad(){
|
||||
this.on(GameEvent.FightStart,this.to_fight,this)
|
||||
this.on(GameEvent.MonDead,this.check_mon,this)
|
||||
this.on(GameEvent.NewWave,this.do_mon_wave,this)
|
||||
}
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
// this.on(ModuleEvent.Cmd, this.onHandler, this);
|
||||
// this.test_call()
|
||||
}
|
||||
|
||||
check_mon(){
|
||||
let mon=ecs.query(ecs.allOf(MonModelComp))
|
||||
console.log("[MissionMonComp]:check_mon",mon)
|
||||
if(mon.length==1) {
|
||||
|
||||
// do 倒计时
|
||||
|
||||
this.do_mon_wave()
|
||||
}
|
||||
}
|
||||
//奖励发放
|
||||
do_reward(){
|
||||
let wave=smc.vmdata.mission_data.current_wave
|
||||
// 奖励发放
|
||||
}
|
||||
|
||||
protected update(dt: number): void {
|
||||
if(!smc.mission.play||smc.mission.pause) return
|
||||
|
||||
if(this.is_fight) {
|
||||
// if(this.timer.update(dt)){
|
||||
// this.do_mon_wave()
|
||||
// }
|
||||
}
|
||||
// 处理刷怪队列
|
||||
if (this.monsterQueue.length > 0 && !this.isSpawning) {
|
||||
this.spawnTimer += dt;
|
||||
@@ -81,18 +56,8 @@ export class MissionMonCompComp extends CCComp {
|
||||
}
|
||||
}
|
||||
|
||||
to_fight(){
|
||||
console.log("[MissionMonComp]:to_fight")
|
||||
this.is_fight=true
|
||||
this.do_mon_wave()
|
||||
this.timer=new Timer(FightSet.MON_WAVE_TIME)
|
||||
}
|
||||
test_call(){
|
||||
this.addToSpawnQueue(5202, 0, true, 1);
|
||||
}
|
||||
|
||||
do_mon_wave(){
|
||||
oops.message.dispatchEvent(GameEvent.WaveUpdate)
|
||||
console.log("[MissionMonComp]:怪物登场,当前波次 :",smc.vmdata.mission_data.current_wave)
|
||||
const currentWave = smc.vmdata.mission_data.current_wave;
|
||||
// 使用肉鸽模式配置
|
||||
@@ -107,7 +72,7 @@ export class MissionMonCompComp extends CCComp {
|
||||
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}战斗波次`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user