public static void Update() { foreach (BaseObject obj in _objs) { obj.Update(); } foreach (Bullet bullet in _bullets) { bullet.Update(); } for (int i = 0; i < _asteroids.Count; i++) { _asteroids[i].Update(); for (int j = 0; j < _bullets.Count; j++) { if (_asteroids.Count != 0 && _bullets[j].Collision(_asteroids[i])) { _score += 100; // Уровень_2.Урок_3.Задание 4: очки за сбитые астероиды System.Media.SystemSounds.Hand.Play(); _asteroids.RemoveAt(i); _bullets.RemoveAt(j); j--; i = 0; //aster.Resurrection(Width); //метод восстановления уничтоженного астероида //_bullet.Resurrection(_spaceShip); //метод нового выстрела после попадения в астероид } else if (_asteroids.Count == 0) { _countAsteroids++; _asteroids.Clear(); CreateAsteroids(); } } if (!_spaceShip.Collision(_asteroids[i])) { continue; } _spaceShip?.EnergyLow(20); System.Media.SystemSounds.Asterisk.Play(); if (_spaceShip.Eneregy <= 0) { _spaceShip?.Die(); } } //Аптечки foreach (MedicineChest chest in _chests) { chest.Update(); if (_spaceShip.Collision(chest)) { _spaceShip?.EnergyUp(10); } System.Media.SystemSounds.Exclamation.Play(); } _spaceShip.Update(); }
public static void Update() { foreach (BaseObject obj in _objs) { obj.Update(); } _bullet?.Update(); for (int i = 0; i < _asteroids.Length; i++) { if (_asteroids[i] == null) { continue; } _asteroids[i].Update(); if (_bullet != null && _bullet.Collision(_asteroids[i])) { _score += 100; // Уровень_2.Урок_3.Задание 4: очки за сбитые астероиды System.Media.SystemSounds.Hand.Play(); _asteroids[i] = null; _bullet = null; continue; //aster.Resurrection(Width); //метод восстановления уничтоженного астероида //_bullet.Resurrection(_spaceShip); //метод нового выстрела после попадения в астероид } if (!_spaceShip.Collision(_asteroids[i])) { continue; } _spaceShip?.EnergyLow(20); System.Media.SystemSounds.Asterisk.Play(); if (_spaceShip.Eneregy <= 0) { _spaceShip?.Die(); } } //Аптечки foreach (MedicineChest chest in _chests) { chest.Update(); if (_spaceShip.Collision(chest)) { _spaceShip?.EnergyUp(10); } System.Media.SystemSounds.Exclamation.Play(); } _spaceShip.Update(); }