技能碰撞改回物理碰撞
This commit is contained in:
@@ -16,6 +16,12 @@ const { ccclass, property } = _decorator;
|
||||
@ecs.register('MissionMonComp', false)
|
||||
export class MissionMonCompComp extends CCComp {
|
||||
timer:Timer=new Timer(3)
|
||||
// 添加刷怪队列
|
||||
private monsterQueue: Array<{uuid: number, position: number, isBoss: boolean}> = [];
|
||||
private isSpawning: boolean = false;
|
||||
private spawnInterval: number = 0.5; // 每个怪物生成间隔时间
|
||||
private spawnTimer: number = 0;
|
||||
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
@@ -28,31 +34,45 @@ export class MissionMonCompComp extends CCComp {
|
||||
this.mon_refresh()
|
||||
}
|
||||
|
||||
// 处理刷怪队列
|
||||
if (this.monsterQueue.length > 0 && !this.isSpawning) {
|
||||
this.spawnTimer += dt;
|
||||
if (this.spawnTimer >= this.spawnInterval) {
|
||||
this.spawnNextMonster();
|
||||
this.spawnTimer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
test_call(){
|
||||
this.addMonster(5202,0,true)
|
||||
this.addToSpawnQueue(5202, 0, true);
|
||||
}
|
||||
|
||||
|
||||
mon_refresh(){
|
||||
let num =3
|
||||
let t_num= Missions[0].length
|
||||
let y_num= Missions[1].length
|
||||
let b_num= Missions[2].length
|
||||
let tc=1
|
||||
let yc=2
|
||||
let bc=1
|
||||
let x=RandomManager.instance.getRandomInt(0,y_num,1)
|
||||
this.addMonster(Missions[0][x],0)
|
||||
x=RandomManager.instance.getRandomInt(0,y_num,1)
|
||||
this.addMonster(Missions[0][x],1)
|
||||
x=RandomManager.instance.getRandomInt(0,y_num,1)
|
||||
this.addMonster(Missions[0][x],2)
|
||||
x=RandomManager.instance.getRandomInt(0,y_num,1)
|
||||
this.addMonster(Missions[0][x],3)
|
||||
let positions = [0, 1, 2, 3];
|
||||
positions.forEach(pos => {
|
||||
let x = RandomManager.instance.getRandomInt(0, Missions[0].length, 1);
|
||||
this.addToSpawnQueue(Missions[0][x], pos, false);
|
||||
});
|
||||
}
|
||||
|
||||
console.log("Missions t:"+x,Missions[0][x])
|
||||
// 新增:添加到刷怪队列
|
||||
private addToSpawnQueue(uuid: number, position: number, isBoss: boolean = false) {
|
||||
this.monsterQueue.push({
|
||||
uuid: uuid,
|
||||
position: position,
|
||||
isBoss: isBoss
|
||||
});
|
||||
}
|
||||
|
||||
// 新增:从队列中生成下一个怪物
|
||||
private spawnNextMonster() {
|
||||
if (this.monsterQueue.length === 0) return;
|
||||
|
||||
const monsterData = this.monsterQueue.shift();
|
||||
if (monsterData) {
|
||||
this.addMonster(monsterData.uuid, monsterData.position, monsterData.isBoss);
|
||||
}
|
||||
}
|
||||
|
||||
private addMonster(uuid:number=1001,i:number=0,is_boss:boolean=false) {
|
||||
|
||||
Reference in New Issue
Block a user