修改mon 、hero的位置更新方法,多线改为单线
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<monsters.length;i++){
|
||||
if(monsters[i].MonView == undefined) return
|
||||
let mon:any = monsters[i].MonView.node.position
|
||||
if(mon.x < smc.enemy_pos[0].x&&mon.y == smc.enemy_pos[0].y){
|
||||
smc.enemy_pos[0].x = mon.x
|
||||
continue
|
||||
}
|
||||
if(mon.x < smc.enemy_pos[1].x&&mon.y == smc.enemy_pos[1].y){
|
||||
smc.enemy_pos[1].x = mon.x
|
||||
continue
|
||||
}
|
||||
if(mon.x < smc.enemy_pos[2].x&&mon.y == smc.enemy_pos[2].y){
|
||||
smc.enemy_pos[2].x = mon.x
|
||||
continue
|
||||
}
|
||||
smc.enemy_pos[i].x= mon.x
|
||||
}
|
||||
}
|
||||
count_hero_pos(){
|
||||
let heros:any= ecs.query(ecs.allOf(HeroModelComp));
|
||||
smc.hero_pos[0].x=-320
|
||||
smc.hero_pos[1].x=-320
|
||||
smc.hero_pos[2].x=-320
|
||||
for(let i=0;i<heros.length;i++){
|
||||
if(heros[i].RoleView != undefined){
|
||||
smc.hero_pos[5].x = heros[i].RoleView.node.position.x
|
||||
smc.hero_pos[5].y = heros[i].RoleView.node.position.y
|
||||
continue
|
||||
}
|
||||
if(heros[i].HeroView == undefined) return
|
||||
let ho:any = heros[i].HeroView.node.position
|
||||
if(ho.x > 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user