This commit is contained in:
2024-09-19 08:39:56 +08:00
parent 01ad8b619e
commit 684ef1619d
10 changed files with 791 additions and 691 deletions

View File

@@ -40,7 +40,6 @@ export class MapMonsterComp extends CCComp {
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);
@@ -94,15 +93,15 @@ export class MapMonsterComp extends CCComp {
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)){
if(mon.x < x&&mon.y == smc.enemy_pos[0].y){
x = mon.x
continue
}
if(mon.x < x1&&mon.y == this.line){
if(mon.x < x1&&mon.y == smc.enemy_pos[1].y){
x1 = mon.x
continue
}
if(mon.x < x2&&mon.y == (this.line -70)){
if(mon.x < x2&&mon.y == smc.enemy_pos[2].y){
x2 = mon.x
continue
}
@@ -119,15 +118,15 @@ export class MapMonsterComp extends CCComp {
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)){
if(ho.x > x&&ho.y == smc.hero_pos[0].y){
x = ho.x
continue
}
if(ho.x > x1&&ho.y == this.line ){
if(ho.x > x1&&ho.y == smc.hero_pos[1].y ){
x1 = ho.x
continue
}
if(ho.x > x2&&ho.y == (this.line -70)){
if(ho.x > x2&&ho.y == smc.hero_pos[2].y){
x2 = ho.x
continue
}
@@ -150,7 +149,7 @@ export class MapMonsterComp extends CCComp {
private addHero(uuid:number=1001) {
let hero = ecs.getEntity<Hero>(Hero);
var scene = smc.map.MapView.scene;
let pos:Vec3 = v3(-280,BoxSet.GAME_LINE+this.start_ys[2]);
let pos:Vec3 = v3(-280,BoxSet.GAME_LINE+this.start_ys[this.hero_index]);
let monster_layer = scene.entityLayer!.node!
let scale = 1
hero.load(pos,scale,uuid,monster_layer);