稍微优化技能目标
This commit is contained in:
@@ -135,55 +135,49 @@ export class SkillConComp extends CCComp {
|
|||||||
return false
|
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{
|
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)
|
|
||||||
}
|
|
||||||
if(entities.length==0){
|
|
||||||
console.log("filterFrontRow 目标不存在",pos.x,pos.y)
|
|
||||||
return pos
|
|
||||||
|
|
||||||
|
// 敌方最前排是x坐标最大的,我方最前排是x坐标最小的,若目标不存在,敌人 取400,我方取-400
|
||||||
|
let pos=v3(0,0)
|
||||||
|
let entities=this.check_target()
|
||||||
|
if(entities.length==0){
|
||||||
|
if(this.HeroView.fac==FacSet.HERO){
|
||||||
|
return v3(400,0)
|
||||||
|
}else{
|
||||||
|
return v3(-400,0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let keyPos = this.HeroView.fac==FacSet.HERO ?
|
pos=v3(this.get_front(entities),0)
|
||||||
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)
|
|
||||||
return pos
|
return pos
|
||||||
}
|
}
|
||||||
|
|
||||||
private selectAllyTargets( ): Vec3 {
|
private selectAllyTargets( ): Vec3 {
|
||||||
// 敌方最前排是x坐标最大的+50,我方最前排是x坐标最小的+50,若目标不存在,敌人 取320/2,我方取-320/2
|
// 敌方最前排是x坐标最大的+50,我方最前排是x坐标最小的+50,若目标不存在,敌人 取320/2,我方取-320/2
|
||||||
let entities:any=null
|
let kp=0
|
||||||
let kp=50
|
|
||||||
let pos=v3(0,0)
|
let pos=v3(0,0)
|
||||||
if(this.HeroView.fac==FacSet.HERO){
|
let entities=this.check_target()
|
||||||
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
|
|
||||||
}
|
|
||||||
if(entities.length==0){
|
if(entities.length==0){
|
||||||
console.log("selectAllyTargets 目标不存在",pos)
|
if(this.HeroView.fac==FacSet.HERO){
|
||||||
return pos
|
return v3(320/2+kp,0)
|
||||||
|
}else{
|
||||||
|
return v3(-320/2-kp,0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let keyPos = this.HeroView.fac==FacSet.HERO ?
|
pos=v3(this.get_front(entities)+kp,0)
|
||||||
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)
|
|
||||||
return pos
|
return pos
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user