本文整理汇总了Golang中github.com/runningwild/haunts/game.Entity.HasLos方法的典型用法代码示例。如果您正苦于以下问题:Golang Entity.HasLos方法的具体用法?Golang Entity.HasLos怎么用?Golang Entity.HasLos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/runningwild/haunts/game.Entity
的用法示例。
在下文中一共展示了Entity.HasLos方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: findTargets
func (a *Interact) findTargets(ent *game.Entity, g *game.Game) []*game.Entity {
var targets []*game.Entity
for _, e := range g.Ents {
x, y := e.Pos()
dx, dy := e.Dims()
if e == ent {
continue
}
if e.ObjectEnt == nil {
continue
}
if e.Sprite().State() != "ready" {
continue
}
if distBetweenEnts(e, ent) > a.Range {
continue
}
if !ent.HasLos(x, y, dx, dy) {
continue
}
// Make sure it's still active:
active := false
active = true
if !active {
continue
}
targets = append(targets, e)
}
return targets
}
示例2: AiBestTarget
func (a *AoeAttack) AiBestTarget(ent *game.Entity, extra_dist int, spec AiAoeTarget) (x, y int, targets []*game.Entity) {
ex, ey := ent.Pos()
max := 0
best_dist := 10000
var bx, by int
var radius int
if a.Range > 0 {
radius += a.Range
}
if extra_dist > 0 {
radius += extra_dist
}
for x := ex - radius; x <= ex+radius; x++ {
for y := ey - radius; y <= ey+radius; y++ {
if !ent.HasLos(x, y, 1, 1) {
continue
}
targets = a.getTargetsAt(ent.Game(), x, y)
ok := true
count := 0
for i := range targets {
if targets[i].Side() != ent.Side() {
count++
} else if ent.Side() == game.SideHaunt && spec == AiAoeHitMinionsOk {
if targets[i].HauntEnt == nil || targets[i].HauntEnt.Level != game.LevelMinion {
ok = false
}
} else if spec != AiAoeHitAlliesOk {
ok = false
}
}
dx := x - ex
if dx < 0 {
dx = -dx
}
dy := y - ey
if dy < 0 {
dy = -dy
}
dist := dx
if dy > dx {
dist = dy
}
if ok && (count > max || count == max && dist < best_dist) {
max = count
best_dist = dist
bx, by = x, y
}
}
}
return bx, by, a.getTargetsAt(ent.Game(), bx, by)
}
示例3: AiAttackPosition
func (a *AoeAttack) AiAttackPosition(ent *game.Entity, x, y int) game.ActionExec {
if !ent.HasLos(x, y, 1, 1) {
base.Log().Printf("Don't have los")
return nil
}
if a.Ap > ent.Stats.ApCur() {
base.Log().Printf("Don't have the ap")
return nil
}
var exec aoeExec
exec.SetBasicData(ent, a)
exec.X, exec.Y = x, y
return &exec
}
示例4: AiInteractWithObject
func (a *Interact) AiInteractWithObject(ent, object *game.Entity) game.ActionExec {
if ent.Stats.ApCur() < a.Ap {
return nil
}
if distBetweenEnts(ent, object) > a.Range {
return nil
}
x, y := object.Pos()
dx, dy := object.Dims()
if !ent.HasLos(x, y, dx, dy) {
return nil
}
var exec interactExec
exec.SetBasicData(ent, a)
exec.Target = object.Id
return &exec
}