稍微优化技能目标
This commit is contained in:
@@ -135,55 +135,49 @@ export class SkillConComp extends CCComp {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
|
||||
check_target(){
|
||||
if(this.HeroView.fac==FacSet.HERO){
|
||||
return ecs.query(ecs.allOf(MonModelComp))
|
||||
}else{
|
||||
return ecs.query(ecs.allOf(HeroModelComp))
|
||||
}
|
||||
}
|
||||
get_front(entities:any){
|
||||
let keyPos = this.HeroView.fac==FacSet.HERO ?
|
||||
Math.min(...entities.map(e => e.get(HeroViewComp).node.position.x)) :
|
||||
Math.max(...entities.map(e => e.get(HeroViewComp).node.position.x));
|
||||
return keyPos
|
||||
}
|
||||
/** 筛选最前排单位 */
|
||||
private filterFrontRow(): Vec3{
|
||||
|
||||
// 敌方最前排是x坐标最大的,我方最前排是x坐标最小的,若目标不存在,敌人 取400,我方取-400
|
||||
let entities:any=null
|
||||
let pos=v3(0,0)
|
||||
if(this.HeroView.fac==FacSet.HERO){
|
||||
entities = ecs.query(ecs.allOf(MonModelComp))
|
||||
pos=v3(400,0)
|
||||
}else{
|
||||
entities = ecs.query(ecs.allOf(HeroModelComp))
|
||||
pos=v3(-400,0)
|
||||
}
|
||||
let entities=this.check_target()
|
||||
if(entities.length==0){
|
||||
console.log("filterFrontRow 目标不存在",pos.x,pos.y)
|
||||
return pos
|
||||
|
||||
if(this.HeroView.fac==FacSet.HERO){
|
||||
return v3(400,0)
|
||||
}else{
|
||||
return v3(-400,0)
|
||||
}
|
||||
}
|
||||
let keyPos = this.HeroView.fac==FacSet.HERO ?
|
||||
Math.min(...entities.map(e => e.get(HeroViewComp).node.position.x)) :
|
||||
Math.max(...entities.map(e => e.get(HeroViewComp).node.position.x));
|
||||
pos=v3(keyPos,0)
|
||||
console.log("filterFrontRow 目标存在",pos.x,pos.y)
|
||||
pos=v3(this.get_front(entities),0)
|
||||
return pos
|
||||
}
|
||||
|
||||
private selectAllyTargets( ): Vec3 {
|
||||
// 敌方最前排是x坐标最大的+50,我方最前排是x坐标最小的+50,若目标不存在,敌人 取320/2,我方取-320/2
|
||||
let entities:any=null
|
||||
let kp=50
|
||||
let kp=0
|
||||
let pos=v3(0,0)
|
||||
if(this.HeroView.fac==FacSet.HERO){
|
||||
entities = ecs.query(ecs.allOf(MonModelComp))
|
||||
pos=v3(320/2+kp,0)
|
||||
}else{
|
||||
entities = ecs.query(ecs.allOf(HeroModelComp))
|
||||
pos=v3(-320/2-kp,0)
|
||||
kp=-50
|
||||
}
|
||||
let entities=this.check_target()
|
||||
if(entities.length==0){
|
||||
console.log("selectAllyTargets 目标不存在",pos)
|
||||
return pos
|
||||
if(this.HeroView.fac==FacSet.HERO){
|
||||
return v3(320/2+kp,0)
|
||||
}else{
|
||||
return v3(-320/2-kp,0)
|
||||
}
|
||||
}
|
||||
let keyPos = this.HeroView.fac==FacSet.HERO ?
|
||||
Math.min(...entities.map(e => e.get(HeroViewComp).node.position.x)) :
|
||||
Math.max(...entities.map(e => e.get(HeroViewComp).node.position.x));
|
||||
pos=v3(keyPos+kp,0)
|
||||
console.log("selectAllyTargets 目标存在",pos)
|
||||
pos=v3(this.get_front(entities)+kp,0)
|
||||
return pos
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user