本文整理汇总了Golang中github.com/runningwild/haunts/game.Game.RecalcLos方法的典型用法代码示例。如果您正苦于以下问题:Golang Game.RecalcLos方法的具体用法?Golang Game.RecalcLos怎么用?Golang Game.RecalcLos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/runningwild/haunts/game.Game
的用法示例。
在下文中一共展示了Game.RecalcLos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Maintain
func (a *Interact) Maintain(dt int64, g *game.Game, ae game.ActionExec) game.MaintenanceStatus {
if ae != nil {
exec := ae.(*interactExec)
a.ent = g.EntityById(ae.EntityId())
if (exec.Target != 0) == (exec.Toggle_door) {
base.Error().Printf("Got an interact that tried to target a door and an entity: %v", exec)
return game.Complete
}
if exec.Target != 0 {
target := g.EntityById(exec.Target)
if target == nil {
base.Error().Printf("Tried to interact with an entity that doesn't exist: %v", exec)
return game.Complete
}
if target.ObjectEnt == nil {
base.Error().Printf("Tried to interact with an entity that wasn't an object: %v", exec)
return game.Complete
}
if target.Sprite().State() != "ready" {
base.Error().Printf("Tried to interact with an object that wasn't in its ready state: %v", exec)
return game.Complete
}
if distBetweenEnts(a.ent, target) > a.Range {
base.Error().Printf("Tried to interact with an object that was out of range: %v", exec)
return game.Complete
}
x, y := target.Pos()
dx, dy := target.Dims()
if !a.ent.HasLos(x, y, dx, dy) {
base.Error().Printf("Tried to interact with an object without having los: %v", exec)
return game.Complete
}
a.ent.Stats.ApplyDamage(-a.Ap, 0, status.Unspecified)
target.Sprite().Command("inspect")
return game.Complete
} else {
// We're interacting with a door here
if exec.Floor < 0 || exec.Floor >= len(g.House.Floors) {
base.Error().Printf("Specified an unknown floor %v", exec)
return game.Complete
}
floor := g.House.Floors[exec.Floor]
if exec.Room < 0 || exec.Room >= len(floor.Rooms) {
base.Error().Printf("Specified an unknown room %v", exec)
return game.Complete
}
room := floor.Rooms[exec.Room]
if exec.Door < 0 || exec.Door >= len(room.Doors) {
base.Error().Printf("Specified an unknown door %v", exec)
return game.Complete
}
door := room.Doors[exec.Door]
x, y := a.ent.Pos()
dx, dy := a.ent.Dims()
ent_rect := makeIntFrect(x, y, x+dx, y+dy)
if !ent_rect.Overlaps(makeRectForDoor(room, door)) {
base.Error().Printf("Tried to open a door that was out of range: %v", exec)
return game.Complete
}
_, other_door := floor.FindMatchingDoor(room, door)
if other_door != nil {
door.SetOpened(!door.IsOpened())
other_door.SetOpened(door.IsOpened())
// if door.IsOpened() {
// sound.PlaySound(door.Open_sound)
// } else {
// sound.PlaySound(door.Shut_sound)
// }
g.RecalcLos()
a.ent.Stats.ApplyDamage(-a.Ap, 0, status.Unspecified)
} else {
base.Error().Printf("Couldn't find matching door: %v", exec)
return game.Complete
}
}
}
return game.Complete
}