本文整理匯總了Golang中github.com/MobRulesGames/haunts/game.Game.DetermineLos方法的典型用法代碼示例。如果您正苦於以下問題:Golang Game.DetermineLos方法的具體用法?Golang Game.DetermineLos怎麽用?Golang Game.DetermineLos使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/MobRulesGames/haunts/game.Game
的用法示例。
在下文中一共展示了Game.DetermineLos方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getTargetsAt
func (a *AoeAttack) getTargetsAt(g *game.Game, tx, ty int) []*game.Entity {
x := tx - (a.Diameter+1)/2
y := ty - (a.Diameter+1)/2
x2 := tx + a.Diameter/2
y2 := ty + a.Diameter/2
// If the diameter is even we need to run los from all four positions
// around the center of the aoe.
num_centers := 1
if a.Diameter%2 == 0 {
num_centers = 4
}
var targets []*game.Entity
for i := 0; i < num_centers; i++ {
// If num_centers is 4 then this will calculate the los for all four
// positions around the center
g.DetermineLos(tx+i%2, ty+i/2, a.Diameter, grid[i])
}
for _, ent := range g.Ents {
entx, enty := ent.Pos()
has_los := false
for i := 0; i < num_centers; i++ {
has_los = has_los || grid[i][entx][enty]
}
if has_los && entx >= x && entx < x2 && enty >= y && enty < y2 {
targets = append(targets, ent)
}
}
algorithm.Choose(&targets, func(e *game.Entity) bool {
return e.Stats != nil
})
return targets
}