修改mon 、hero的位置更新方法,多线改为单线
This commit is contained in:
@@ -45,7 +45,7 @@ export enum GameSet {
|
|||||||
ATK_TO_HP_RATIO=0.2,
|
ATK_TO_HP_RATIO=0.2,
|
||||||
ATK_TO_SHIELD_RATIO=2,
|
ATK_TO_SHIELD_RATIO=2,
|
||||||
|
|
||||||
ATK_LINES = 6,
|
ATK_LINES = 6, //英雄数
|
||||||
MON_GOLD_ADD =2,
|
MON_GOLD_ADD =2,
|
||||||
MON_COIN_ADD=2,
|
MON_COIN_ADD=2,
|
||||||
COIN_ADD=1,
|
COIN_ADD=1,
|
||||||
|
|||||||
@@ -207,19 +207,28 @@ export class HeroViewComp extends CCComp {
|
|||||||
check_enemy_alive(){
|
check_enemy_alive(){
|
||||||
let dir = 320
|
let dir = 320
|
||||||
this.enemy = v3(720,this.node.position.y)
|
this.enemy = v3(720,this.node.position.y)
|
||||||
for (let i = 0; i < GameSet.ATK_LINES; i++) {
|
if(this.box_group == BoxSet.MONSTER){
|
||||||
|
for (let i = 0; i < smc.hero_pos.length; i++) {
|
||||||
let mon:any = smc.enemy_pos[i];
|
let ho:any = smc.hero_pos[i];
|
||||||
let x=Math.abs(mon.x-this.node.position.x)
|
let x=Math.abs(ho.x-this.node.position.x)
|
||||||
let y = Math.abs(mon.y-this.node.position.y)
|
if(x < dir){
|
||||||
let squaredDistance =x*x+y*y
|
dir = x
|
||||||
let distance = Math.sqrt(squaredDistance);
|
this.enemy = ho
|
||||||
if(distance < dir){
|
}
|
||||||
dir = distance
|
|
||||||
this.enemy = mon
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
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){
|
if(dir < this.atk_dis){
|
||||||
this.is_atking=true
|
this.is_atking=true
|
||||||
this.stop_cd = 0.1
|
this.stop_cd = 0.1
|
||||||
|
|||||||
@@ -189,51 +189,18 @@ export class MapMonsterComp extends CCComp {
|
|||||||
}
|
}
|
||||||
count_mon_pos(){
|
count_mon_pos(){
|
||||||
let monsters:any= ecs.query(ecs.allOf(MonModelComp));
|
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++){
|
for(let i=0;i<monsters.length;i++){
|
||||||
if(monsters[i].MonView == undefined) return
|
if(monsters[i].MonView == undefined) return
|
||||||
let mon:any = monsters[i].MonView.node.position
|
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[i].x= mon.x
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
count_hero_pos(){
|
count_hero_pos(){
|
||||||
let heros:any= ecs.query(ecs.allOf(HeroModelComp));
|
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++){
|
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
|
if(heros[i].HeroView == undefined) return
|
||||||
let ho:any = heros[i].HeroView.node.position
|
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[i].x= ho.x
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// console.log("count_hero_pos",smc.hero_pos);
|
// console.log("count_hero_pos",smc.hero_pos);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user