public static void Update() { ConsoleMessage <string> strTarget = new ConsoleMessage <string>(StringTarget); //foreach (BaseObject obj in objs) obj.Update(); bullet?.Update(); heal?.Update(); if (heal != null && heal.Collision(ship)) { if (ship.Energy <= 90) { ship?.EnergyHeal(10); strTarget("Ship is healed"); } else { ship.EnergyClear(); } Random rnd = new Random(); heal = new Heal(new Point(Game.Width, rnd.Next(20, 1000)), new Point(rnd.Next(3, 10), rnd.Next(3, 10)), new Size(5, 5)); } for (var i = 0; i < asteroids.Length; i++) { if (asteroids[i] == null) { continue; } asteroids[i].Update(); if (bullet != null && bullet.Collision(asteroids[i])) { System.Media.SystemSounds.Hand.Play(); asteroids[i] = null; bullet = null; Count++; strTarget("Asteroid is hit"); continue; } if (!ship.Collision(asteroids[i])) { continue; } var rnd = new Random(); ship?.EnergyLow(rnd.Next(1, 10)); strTarget("Ship is hit"); System.Media.SystemSounds.Asterisk.Play(); if (ship.Energy <= 0) { ship?.Die(); } } }