本文整理汇总了Golang中github.com/runningwild/haunts/game.Game.DoAttack方法的典型用法代码示例。如果您正苦于以下问题:Golang Game.DoAttack方法的具体用法?Golang Game.DoAttack怎么用?Golang Game.DoAttack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/runningwild/haunts/game.Game
的用法示例。
在下文中一共展示了Game.DoAttack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Maintain
func (a *AoeAttack) Maintain(dt int64, g *game.Game, ae game.ActionExec) game.MaintenanceStatus {
if ae != nil {
a.exec = ae.(*aoeExec)
a.targets = a.getTargetsAt(g, a.exec.X, a.exec.Y)
if a.Current_ammo > 0 {
a.Current_ammo--
}
a.ent = g.EntityById(ae.EntityId())
if !a.ent.HasLos(a.exec.X, a.exec.Y, 1, 1) {
base.Error().Printf("Entity %d tried to target position (%d, %d) with an aoe but doesn't have los to it: %v", a.ent.Id, a.exec.X, a.exec.Y, a.exec)
return game.Complete
}
if a.Ap > a.ent.Stats.ApCur() {
base.Error().Printf("Got an aoe attack that required more ap than available: %v", a.exec)
return game.Complete
}
a.ent.Stats.ApplyDamage(-a.Ap, 0, status.Unspecified)
// Track this information for the ais - the attacking ent will only
// remember one ent that it hit, but that's ok
for _, target := range a.targets {
if target.Side() != a.ent.Side() {
target.Info.LastEntThatAttackedMe = a.ent.Id
a.ent.Info.LastEntThatIAttacked = target.Id
}
}
}
if a.ent.Sprite().State() != "ready" {
return game.InProgress
}
for _, target := range a.targets {
if target.Stats.HpCur() > 0 && target.Sprite().State() != "ready" {
return game.InProgress
}
}
a.ent.TurnToFace(a.exec.X, a.exec.Y)
for _, target := range a.targets {
target.TurnToFace(a.ent.Pos())
}
a.ent.Sprite().Command(a.Animation)
for _, target := range a.targets {
if g.DoAttack(a.ent, target, a.Strength, a.Kind) {
for _, name := range a.Conditions {
target.Stats.ApplyCondition(status.MakeCondition(name))
}
target.Stats.ApplyDamage(0, -a.Damage, a.Kind)
if target.Stats.HpCur() <= 0 {
target.Sprite().CommandN([]string{"defend", "killed"})
} else {
target.Sprite().CommandN([]string{"defend", "damaged"})
}
} else {
target.Sprite().CommandN([]string{"defend", "undamaged"})
}
}
return game.Complete
}