public void FireOnInvader(IInvader[] invaders) { foreach (IInvader invader in invaders) { if (invader.IsActive && location.InRangeOf(invader.Location, Range)) { invader.DecreaseHealth(Power); } } }
// Loops through the invaders array and shoots at them public void FireOnInvaders(Invader[] invaders) { foreach (Invader invader in invaders) { if (invader.IsActive && _location.InRangeOf(invader.Location, Range)) { if (IsSuccessfulShot()) { invader.DecreaseHealth(Power); Console.WriteLine("Shot at and hit an invader!"); if (invader.IsNeutralized) { Console.WriteLine("Neutralized an invader!"); } } else { Console.WriteLine("Shot at and missed an invader"); } break; } } }