/// <summary> /// Метод запуска бонуса, по таймеру /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void StartBonus() { timerBonus.Stop(); heart = new HeartForLife(); Log($"Аптечка создана."); timerBonus.Interval = Game.Rnd.Next(BonusTimeMin, BonusTimeMax); }
public static void Update() { for (int i = 0; i < stars.Length; i++) { if (stars[i] == null) { stars[i] = new Star(new Size(Rnd.Next(0, 5), Rnd.Next(0, 5)), true); } else { stars[i].Update(ref stars[i]); } if (stars[i].Position.X < 0) { stars[i] = null; } } for (int i = 0; i < ListAsteroid.Length; i++) { if (ListAsteroid[i] == null) { ListAsteroid[i] = new Asteroid(imageAsteroid); } ListAsteroid[i]?.Update(ref ListAsteroid[i]); if (BulletHits(ref ListAsteroid[i])) { continue; } if (ListAsteroid[i] != null && ship.Collision(ListAsteroid[i])) { Log("Корабль подбит"); timerBonus.Start(); ListAsteroid[i] = null; ship.Damage(); } } for (int i = 0; i < bullets.Length; ++i) { if (bullets[i] != null) { bullets[i].Update(ref bullets[i]); } } SystemSounds.Asterisk.Play(); ship.Update(ref ship); if (ship.Live <= 0) { ship?.Die(); } if (heart != null) { if (heart.Collision(ship)) { Log("Колличество жизней увеличено"); ship.Heal(); heart = null; } heart?.Update(ref heart); } GC.Collect(); }