public static void Update() { foreach (BaseObject obj in _objs) { obj.Update(); } //foreach (Asteroid a in _asteroids) //{ // a.Update(); // //if (a.Collision(_bullet)) // //{ // // System.Media.SystemSounds.Hand.Play(); // // // регенирируем объекты // // a.Ressurect(); // // _bullet.Ressurect(); // //} //} foreach (Heal a in _heals) { a.Update(); if (a.Collision(_ship)) { System.Media.SystemSounds.Question.Play(); // регенирируем объекты _ship.Heal(25); a.Ressurect(); } } //_bullet?.Update(); foreach (Bullet b in _bullets) { b.Update(); } if (_asteroids.Count == 0) { InitAster(++_aCount); // создание астероидов теперь только тут } bool aster_removed = false; for (var i = 0; i < _asteroids.Count; i++) { if (_asteroids[i] == null) { continue; } _asteroids[i].Update(); aster_removed = false; for (int j = 0; j < _bullets.Count; j++) { if (_asteroids[i] != null && _bullets[j].Collision(_asteroids[i])) { System.Media.SystemSounds.Hand.Play(); _asteroids.RemoveAt(i); _bullets.RemoveAt(j); i--; j--; Score++; aster_removed = true; break; } } if (aster_removed) { continue; } if (_asteroids[i] == null || !_ship.Collision(_asteroids[i])) { continue; } _ship?.EnergyLow(10); System.Media.SystemSounds.Asterisk.Play(); if (_ship.Energy <= 0) { _ship.Die(); } _asteroids.RemoveAt(i); //if (_bullet != null && _bullet.Collision(_asteroids[i])) //{ // System.Media.SystemSounds.Hand.Play(); // _asteroids[i] = null; // _bullet = null; // Score++; // continue; //} //if (!_ship.Collision(_asteroids[i])) continue; ////var rnd = new Random(); //_asteroids[i].Loggin("Ship hit!"); //System.Media.SystemSounds.Asterisk.Play(); //_asteroids[i] = null; //if (_ship.Energy <= 0) _ship?.Die(); } }