/// <summary> /// Изменяет состояние объектов /// </summary> public static void Update() { foreach (Bullet b in _bullets) { b?.Update(); } foreach (BaseObject obj in _star) { obj.Update(); } foreach (BaseObject obj in _grayPlanet) { obj.Update(); } foreach (BaseObject obj in _redPlanet) { obj.Update(); } for (var i = 0; i < _asteroids.Count; i++) { if (AsteroidsCount == 0) { GenerateAsteroid(_asteroids.Count + AsteroidsCountIncrement); AsteroidsCount = _asteroids.Count; } if (_asteroids[i] == null) { continue; } _asteroids[i].Update(); for (var j = 0; j < _bullets.Count; j++) { if (_asteroids[i] != null && _bullets[j].Collision(_asteroids[i])) { System.Media.SystemSounds.Hand.Play(); _asteroids[i] = null; _bullets.RemoveAt(j); _ship?.EnergyIncrease(); j--; AsteroidsCount--; } } if (_asteroids[i] == null || !_ship.Collision(_asteroids[i])) { continue; } { var rnd = new Random(); _ship?.EnergyLow(rnd.Next(10, 20)); System.Media.SystemSounds.Asterisk.Play(); _asteroids[i] = null; AsteroidsCount--; } if (_ship.Energy <= 0) { _ship?.Die(); } } for (var i = 0; i < _fik.Length; i++) { _fik[i].Update(); if (!_ship.Collision(_fik[i])) { continue; } if (_ship.Energy >= 100) { break; } else { _ship?.EnergyIncrease(); System.Media.SystemSounds.Exclamation.Play(); } } }