本文整理汇总了Golang中github.com/runningwild/magnus/game.Game.DoForEnts方法的典型用法代码示例。如果您正苦于以下问题:Golang Game.DoForEnts方法的具体用法?Golang Game.DoForEnts怎么用?Golang Game.DoForEnts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/runningwild/magnus/game.Game
的用法示例。
在下文中一共展示了Game.DoForEnts方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Think
func (p *pullProcess) Think(g *game.Game) {
defer p.reset()
player, ok := g.Ents[p.PlayerGid].(*game.PlayerEnt)
if !ok {
return
}
base_force := p.Force * p.supplied / p.required()
g.DoForEnts(func(gid game.Gid, ent game.Ent) {
if ent == game.Ent(player) {
return
}
target_pos := ent.Pos()
ray := target_pos.Sub(player.Pos())
target_angle := ray.Angle() - player.Angle
for target_angle < 0 {
target_angle += math.Pi * 2
}
for target_angle > math.Pi*2 {
target_angle -= math.Pi * 2
}
if target_angle > p.Angle/2 && target_angle < math.Pi*2-p.Angle/2 {
return
}
ray = player.Pos().Sub(ent.Pos())
// dist := ray.Mag()
ray = ray.Norm()
force := base_force // / math.Pow(dist, p.Angle/(2*math.Pi))
ent.ApplyForce(ray.Scale(-force))
player.ApplyForce(ray.Scale(force).Scale(0.01))
})
}
示例2: Think
func (p *burstProcess) Think(g *game.Game) {
player, ok := g.Ents[p.PlayerGid].(*game.PlayerEnt)
if !ok {
return
}
if p.Remaining_initial.Magnitude() == 0 {
if p.count > 0 {
p.count = -1
}
p.Frames--
if p.Frames <= 0 {
p.The_phase = game.PhaseComplete
}
g.DoForEnts(func(gid game.Gid, other game.Ent) {
if other == player {
return
}
dist := other.Pos().Sub(player.Pos()).Mag()
if dist < 1 {
dist = 1
}
force := p.Force / dist
other.ApplyForce(other.Pos().Sub(player.Pos()).Norm().Scale(force))
})
}
}
示例3: Think
func (f *fireProcessExplosion) Think(g *game.Game) {
g.DoForEnts(func(gid game.Gid, ent game.Ent) {
for _, expl := range f.Explosions {
if expl.Size() == 0 {
continue
}
if expl.Pos.Sub(ent.Pos()).Mag() <= expl.Size() {
ent.Stats().ApplyDamage(stats.Damage{stats.DamageFire, 1})
}
}
})
done := true
for i := range f.Explosions {
f.Explosions[i].Think()
if !f.Explosions[i].Done() {
done = false
}
}
if done {
f.The_phase = game.PhaseComplete
}
}