// Fire tells the Mech to fire at a Target func (m *Mech) Fire(rangeToTarget int, target weapon.Target) { for _, weapon := range m.weapons { result := weapon.Fire(rangeToTarget, target) if result == false { m.notifier.AddMessage("Missed " + target.Name()) } } }
func (m *Mech) attack(target weapon.Target) { if target == nil { return } if target.IsDestroyed() { return } targetX, targetY := target.Position() distance := util.CalculateDistance(m.prevX, m.prevY, targetX, targetY) m.Fire((int)(distance), target) m.game.Log("distance " + strconv.Itoa((int)(distance))) m.game.Log("firer (%d,%d), target (%d,%d)", m.prevX, m.prevY, targetX, targetY) }