public Ammo Shoot() { if (LoadedAmmo != null) { Ammo firedAmmo = (Ammo)LoadedAmmo.Clone(); ammos.Remove(LoadedAmmo); Random rnd = new Random(); int dice = rnd.Next(0, 100); bool hit = gun.isOnTarget(dice); if (hit) { Console.WriteLine("Попадание!"); return(firedAmmo); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Промах!"); Console.ResetColor(); return(null); } } else { Console.WriteLine("не заряжено"); } return(null); }
public Ammo Shoot() { if (LoadedAmmo != null) { Console.Write($"Танк " + this.model + "выстрелил " + LoadedAmmo.type + " снаряд......"); Ammo firedAmmo = (Ammo)LoadedAmmo.Clone(); ammos.Remove(LoadedAmmo); LoadedAmmo = null; Random rnd = new Random(); int dice = rnd.Next(0, 100); bool hit = this.gun.IsOnTarget(dice); if (this.gun.IsOnTarget(dice)) { Console.WriteLine("Попадание!"); return(firedAmmo); } else { Console.WriteLine("Промах!"); return(null); } } else { Console.WriteLine("не заряжено"); } return(null); }