添加2个游戏层,敌方精灵随机出现在3个层内

This commit is contained in:
2024-08-22 22:59:43 +08:00
parent 6e9faca1a3
commit 2917c12f14
65 changed files with 394 additions and 2540 deletions

View File

@@ -29,7 +29,7 @@ export class MapMonsterComp extends CCComp {
cur_mission:number = 1; //当前关卡方案
mission_list:any = []
setp_timer: Timer = new Timer(0.5);
setp_num:number = 50;
setp_num:number = 5;
onLoad(){
// 监听全局事件
oops.message.on("do_add_monster", this.on_do_add_monster, this);
@@ -40,7 +40,7 @@ export class MapMonsterComp extends CCComp {
let num =RandomManager.instance.getRandomByObjectList(MissionNum,1)
this.cur_mission = num[0]
this.mission_list = MonsetList[this.cur_mission]
console.log("当前关卡方案",this.cur_mission,this.mission_list)
// console.log("当前关卡方案",this.cur_mission,this.mission_list)
this.refresh_timer= new Timer(smc.vm_data.gold.cd);
this.monster_refresh()
}
@@ -49,7 +49,7 @@ export class MapMonsterComp extends CCComp {
this.monster_refresh()
}
if (this.refresh_timer.update(dt)) {
this.setp_num = RandomManager.instance.getRandomInt(this.min_monster_num,this.max_monster_num,2)
// this.setp_num = RandomManager.instance.getRandomInt(this.min_monster_num,this.max_monster_num,2)
}
if (this.mission_up_timer.update(dt)) {
// 刷新怪物定时器
@@ -64,22 +64,36 @@ export class MapMonsterComp extends CCComp {
if (this.setp_num <= 0){
return
}
console.log("当前波数",this.cur_count)
console.log("当前怪物池",this.mission_list[this.monster_level])
// console.log("当前波数",this.cur_count)
// console.log("当前怪物池",this.mission_list[this.monster_level])
let m:any = RandomManager.instance.getRandomByObjectList(this.mission_list[this.monster_level],1)
console.log("刷怪",m)
// console.log("刷怪",m)
this.addMonster(m[0])
this.setp_num -= 1
}
private addMonster(uuid:number=1101) {
let monster = ecs.getEntity<Monster>(Monster);
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE)
let scale = -1
monster.load(pos,scale,uuid);
var scene = smc.map.MapView.scene;
let x = RandomManager.instance.getRandomInt(0,2, 2);
let monster_layer = scene.entityLayer!.node!
switch (x) {
case 1:
monster_layer = scene.entityLayer1!.node!;
pos.y=pos.y+5;
break;
case 2:
monster_layer= scene.entityLayer2!.node!;
pos.y=pos.y-5;
default:
break;
}
monster.load(pos,scale,uuid,monster_layer);
smc.monsters.splice(0,1)
}
private on_do_add_monster(event: string, args: any) {
// this.addMonster(args.uuid)
}