需要修复 英雄目标错误

This commit is contained in:
2024-09-18 17:45:23 +08:00
parent 2ab7279b04
commit 01ad8b619e
17 changed files with 834 additions and 1723 deletions

View File

@@ -34,11 +34,13 @@ export class MapMonsterComp extends CCComp {
mission_list:any = []
setp_timer: Timer = new Timer(0.3);
target_timer: Timer = new Timer(0.1);
setp_num:number = 5;
setp_num:number = 6;
game_over:boolean = false;
start_ys:any[] = [70,0,-70];
hero_start_ys:any[] = [35,-35];
mon_index:number = 0
hero_index:number = 0
line:number=BoxSet.GAME_LINE
onLoad(){
// 监听全局事件
oops.message.on("other_add_monster", this.on_other_add_monster, this);
@@ -65,13 +67,14 @@ export class MapMonsterComp extends CCComp {
this.monster_refresh()
}
if (this.refresh_timer.update(dt)) {
this.setp_num = 5
this.setp_num = 6
}
if (this.mission_up_timer.update(dt)) {
// 刷新怪物定时器
this.cur_count += 1;
}
this.count_hero_pos()
this.count_mon_pos()
// if (this.game_timer.update(dt)) {
// smc.vm_data.game.g_time += 1;
// }
@@ -83,6 +86,56 @@ export class MapMonsterComp extends CCComp {
count = list.length
return count;
}
count_mon_pos(){
let monsters:any= ecs.query(ecs.allOf(MonModelComp));
let x = 320
let x1 = 320
let x2 = 320
for(let i=0;i<monsters.length;i++){
if(monsters[i].MonView == undefined) return
let mon:any = monsters[i].MonView.node.position
if(mon.x < x&&mon.y == (this.line +70)){
x = mon.x
continue
}
if(mon.x < x1&&mon.y == this.line){
x1 = mon.x
continue
}
if(mon.x < x2&&mon.y == (this.line -70)){
x2 = mon.x
continue
}
}
smc.enemy_pos[0].x=x
smc.enemy_pos[1].x=x1
smc.enemy_pos[2].x=x2
}
count_hero_pos(){
let heros:any= ecs.query(ecs.allOf(HeroModelComp));
let x = -320
let x1 = -320
let x2 = -320
for(let i=0;i<heros.length;i++){
if(heros[i].HeroView == undefined) return
let ho:any = heros[i].HeroView.node.position
if(ho.x > x&&ho.y == (this.line +70)){
x = ho.x
continue
}
if(ho.x > x1&&ho.y == this.line ){
x1 = ho.x
continue
}
if(ho.x > x2&&ho.y == (this.line -70)){
x2 = ho.x
continue
}
}
smc.hero_pos[0].x=x
smc.hero_pos[1].x=x1
smc.hero_pos[2].x=x2
}
load_role(){
let role = ecs.getEntity<Role>(Role);
let pos = v3(BoxSet.HERO_START+50,BoxSet.GAME_LINE)
@@ -97,23 +150,28 @@ export class MapMonsterComp extends CCComp {
private addHero(uuid:number=1001) {
let hero = ecs.getEntity<Hero>(Hero);
var scene = smc.map.MapView.scene;
let oy=RandomManager.instance.getRandomByObjectList(this.start_ys,1)
let pos:Vec3 = v3(-280,BoxSet.GAME_LINE+oy[0]);
let pos:Vec3 = v3(-280,BoxSet.GAME_LINE+this.start_ys[2]);
let monster_layer = scene.entityLayer!.node!
let scale = 1
hero.load(pos,scale,uuid,monster_layer);
this.hero_index += 1
if(this.hero_index > 2){
this.hero_index = 0
}
}
monster_refresh(){
if (this.setp_num <= 0){
return
}
let m:any = RandomManager.instance.getRandomByObjectList(this.mission_list[this.monster_level],1)
let m:any = RandomManager.instance.getRandomByObjectList(this.mission_list[this.monster_level],3)
var scene = smc.map.MapView.scene;
let oy=RandomManager.instance.getRandomInt(-70,70,1)
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE+oy)
let pos:Vec3 = v3(BoxSet.MONSTER_START,BoxSet.GAME_LINE+this.start_ys[this.mon_index])
let monster_layer = scene.entityLayer!.node!
this.addMonster(m[0],monster_layer,pos)
this.mon_index += 1
if(this.mon_index>2){
this.mon_index = 0
}
this.setp_num -= 1
}
private addMonster(uuid:number=1001,layer:any,pos:Vec3=v3(0,0,0)) {