diff --git a/assets/script/game/common/config/BoxSet.ts b/assets/script/game/common/config/BoxSet.ts index d22174f2..59fdc7bb 100644 --- a/assets/script/game/common/config/BoxSet.ts +++ b/assets/script/game/common/config/BoxSet.ts @@ -45,7 +45,7 @@ export enum GameSet { ATK_TO_HP_RATIO=0.2, ATK_TO_SHIELD_RATIO=2, - ATK_LINES = 6, + ATK_LINES = 6, //英雄数 MON_GOLD_ADD =2, MON_COIN_ADD=2, COIN_ADD=1, diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index 355af0f1..b4592a39 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -207,19 +207,28 @@ export class HeroViewComp extends CCComp { check_enemy_alive(){ let dir = 320 this.enemy = v3(720,this.node.position.y) - for (let i = 0; i < GameSet.ATK_LINES; i++) { - - let mon:any = smc.enemy_pos[i]; - let x=Math.abs(mon.x-this.node.position.x) - let y = Math.abs(mon.y-this.node.position.y) - let squaredDistance =x*x+y*y - let distance = Math.sqrt(squaredDistance); - if(distance < dir){ - dir = distance - this.enemy = mon + if(this.box_group == BoxSet.MONSTER){ + for (let i = 0; i < smc.hero_pos.length; i++) { + let ho:any = smc.hero_pos[i]; + let x=Math.abs(ho.x-this.node.position.x) + if(x < dir){ + dir = x + this.enemy = ho + } } - } + if(this.box_group == BoxSet.HERO){ + for (let i = 0; i < smc.enemy_pos.length; i++) { + let mon:any = smc.enemy_pos[i]; + let x=Math.abs(mon.x-this.node.position.x) + if(x < dir){ + dir = x + this.enemy = mon + } + } + } + + if(dir < this.atk_dis){ this.is_atking=true this.stop_cd = 0.1 diff --git a/assets/script/game/map/MapMonsterComp.ts b/assets/script/game/map/MapMonsterComp.ts index 69f2ec3a..d01765a1 100644 --- a/assets/script/game/map/MapMonsterComp.ts +++ b/assets/script/game/map/MapMonsterComp.ts @@ -189,51 +189,18 @@ export class MapMonsterComp extends CCComp { } count_mon_pos(){ let monsters:any= ecs.query(ecs.allOf(MonModelComp)); - smc.enemy_pos[0].x=320 - smc.enemy_pos[1].x=320 - smc.enemy_pos[2].x=320 for(let i=0;i smc.hero_pos[0].x&&ho.y == smc.hero_pos[0].y){ - smc.hero_pos[0].x = ho.x - continue - } - if(ho.x > smc.hero_pos[0].x&&ho.y == smc.hero_pos[1].y ){ - smc.hero_pos[1].x = ho.x - continue - } - if(ho.x > smc.hero_pos[0].x&&ho.y == smc.hero_pos[2].y){ - smc.hero_pos[2].x = ho.x - continue - } + smc.hero_pos[i].x= ho.x } // console.log("count_hero_pos",smc.hero_pos); }