修改mon 、hero的位置更新方法,多线改为单线
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user