private void ResetGame()
        {
            if (_chopperGenerator != null)
            {
                _chopperGenerator.StopGenerating();
            }

            _bulletList.DeactivateAllObjects(obj => RemoveGameObject(obj));
            _missileList.DeactivateAllObjects(obj => RemoveGameObject(obj));
            _enemyList.DeactivateAllObjects(obj => RemoveGameObject(obj));
            _explosionList.DeactivateAllObjects(obj => RemoveGameObject(obj));
            _turretBulletList.DeactivateAllObjects(obj => RemoveGameObject(obj));
            _turretList.DeactivateAllObjects(obj => RemoveGameObject(obj));

            _playerSprite.Activate();
            AddGameObject(_playerSprite);

            // position the player in the middle of the screen, at the bottom, leaving a slight gap at the bottom
            var playerXPos = _viewportWidth / 2 - _playerSprite.Width / 2;
            var playerYPos = _viewportHeight - _playerSprite.Height - 30;

            _playerSprite.Position = new Vector2(playerXPos, playerYPos);

            _playerDead = false;
            _level.Reset();
        }
Ejemplo n.º 2
0
        private void ResetGame()
        {
            if (_chopperGenerator != null)
            {
                _chopperGenerator.StopGenerating();
            }

            foreach (var bullet in _bulletList)
            {
                RemoveGameObject(bullet);
            }

            foreach (var missile in _missileList)
            {
                RemoveGameObject(missile);
            }

            foreach (var chopper in _enemyList)
            {
                RemoveGameObject(chopper);
            }

            foreach (var explosion in _explosionList)
            {
                RemoveGameObject(explosion);
            }

            foreach (var bullet in _turretBulletList)
            {
                RemoveGameObject(bullet);
            }

            foreach (var turret in _turretList)
            {
                RemoveGameObject(turret);
            }

            _bulletList       = new List <BulletSprite>();
            _turretBulletList = new List <TurretBulletSprite>();
            _turretList       = new List <TurretSprite>();
            _missileList      = new List <MissileSprite>();
            _explosionList    = new List <ExplosionEmitter>();
            _enemyList        = new List <ChopperSprite>();

            AddGameObject(_playerSprite);

            // position the player in the middle of the screen, at the bottom, leaving a slight gap at the bottom
            var playerXPos = _viewportWidth / 2 - _playerSprite.Width / 2;
            var playerYPos = _viewportHeight - _playerSprite.Height - 30;

            _playerSprite.Position = new Vector2(playerXPos, playerYPos);

            _playerDead = false;
            _level.Reset();
        }