コード例 #1
0
        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();
        }