本文整理汇总了Golang中github.com/runningwild/haunts/game.Game.FromVertex方法的典型用法代码示例。如果您正苦于以下问题:Golang Game.FromVertex方法的具体用法?Golang Game.FromVertex怎么用?Golang Game.FromVertex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/runningwild/haunts/game.Game
的用法示例。
在下文中一共展示了Game.FromVertex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Push
func (exec summonExec) Push(L *lua.State, g *game.Game) {
exec.BasicActionExec.Push(L, g)
if L.IsNil(-1) {
return
}
_, x, y := g.FromVertex(exec.Pos)
L.PushString("Pos")
game.LuaPushPoint(L, x, y)
L.SetTable(-3)
}
示例2: Maintain
func (a *Move) Maintain(dt int64, g *game.Game, ae game.ActionExec) game.MaintenanceStatus {
if ae != nil {
exec := ae.(*moveExec)
a.ent = g.EntityById(ae.EntityId())
if len(exec.Path) == 0 {
base.Error().Printf("Got a move exec with a path length of 0: %v", exec)
return game.Complete
}
a.cost = exec.measureCost(a.ent, g)
if a.cost > a.ent.Stats.ApCur() {
base.Error().Printf("Got a move that required more ap than available: %v", exec)
base.Error().Printf("Path: %v", exec.Path)
return game.Complete
}
if a.cost == -1 {
base.Error().Printf("Got a move that followed an invalid path: %v", exec)
base.Error().Printf("Path: %v", exec.Path)
if a.ent == nil {
base.Error().Printf("ENT was Nil!")
} else {
x, y := a.ent.Pos()
v := g.ToVertex(x, y)
base.Error().Printf("Ent pos: (%d, %d) -> (%d)", x, y, v)
}
return game.Complete
}
algorithm.Map2(exec.Path, &a.path, func(v int) [2]int {
_, x, y := g.FromVertex(v)
return [2]int{x, y}
})
base.Log().Printf("Path Validated: %v", exec)
a.ent.Stats.ApplyDamage(-a.cost, 0, status.Unspecified)
src := g.ToVertex(a.ent.Pos())
graph := g.Graph(a.ent.Side(), true, nil)
a.drawPath(a.ent, g, graph, src)
}
// Do stuff
factor := float32(math.Pow(2, a.ent.Walking_speed))
dist := a.ent.DoAdvance(factor*float32(dt)/200, a.path[0][0], a.path[0][1])
for dist > 0 {
if len(a.path) == 1 {
a.ent.DoAdvance(0, 0, 0)
a.ent.Info.RoomsExplored[a.ent.CurrentRoom()] = true
a.ent = nil
return game.Complete
}
a.path = a.path[1:]
a.ent.Info.RoomsExplored[a.ent.CurrentRoom()] = true
dist = a.ent.DoAdvance(dist, a.path[0][0], a.path[0][1])
}
return game.InProgress
}
示例3: Push
func (exec *moveExec) Push(L *lua.State, g *game.Game) {
exec.BasicActionExec.Push(L, g)
if L.IsNil(-1) {
return
}
L.PushString("Path")
L.NewTable()
for i := range exec.Path {
L.PushInteger(i + 1)
_, x, y := g.FromVertex(exec.Path[i])
game.LuaPushPoint(L, x, y)
L.SetTable(-3)
}
L.SetTable(-3)
}