Game Impovement
Our basic feature in our game already finished, now we could make some improvement.
First improvement is create a random probability, so the tower could miss the shoot to invader.
private static readonly Random _random = new Random();
private const double _accuracy = 0.75;
Now we use it to make a conditional statement if the random generator less than 0.75.
if (invader.IsActive && _location.InRangeOf(invader.Location, _range))
{
if (_random.NextDouble() < _accuracy)
{
invader.decreaseHealth(_power);
Console.WriteLine("invader shooted succesfully");
if (invader.IsNeutralized)
Console.WriteLine("invader neutralized");
}
else
{
Console.WriteLine("invader shooted missed");
}
break;
}
And it will be not predictable and more fun.