Пример #1
0
        public void StartGame()
        {
            // Set the GameOver property to false
            GameOver = false;

            // Clear all invaders, shots, and stars
            foreach (Invader invader in _invaders)
                OnShipChanged(invader as Ship, true);
            _invaders.Clear();

            foreach (Shot shot in _playerShots)
                OnShotMoved(shot, true);
            _playerShots.Clear();

            foreach (Shot shot in _invaderShots)
                OnShotMoved(shot, true);
            _invaderShots.Clear();

            foreach (Point star in _stars)
                OnStarChanged(star, true);
            _stars.Clear();

            // Create new stars
            for (int i = 0; i < InitialStarCount; i++)
                AddStar();

            // Add the player
            _player = new Player();
            OnShipChanged(_player, false);

            // Initialize game statistics
            Lives = 2;
            Wave = 0;
            Score = 0;

            // Add the first wave of invaders
            nextWave();
        }
Пример #2
0
        /// <summary>
        /// Starts new game
        /// </summary>
        public void StartGame()
        {
            // Clear game objects
            GameOver = false;
            foreach (Invader invader in _invaders)
                OnShipChanged(invader, true); //TODO: Check if killed parameter really should be true
            _invaders.Clear();

            foreach (Shot invadersShot in _invaderShots)
                OnShotMoved(invadersShot, true);
            _invaderShots.Clear();

            foreach (Shot playerShot in _playerShots)
                OnShotMoved(playerShot, true);
            _playerShots.Clear();

            foreach (var star in _stars)
                OnStarChanged(star, true);
            _stars.Clear();

            // Create new game objects
            AddNewStars(InitialStarCount);
            _player = new Player(_playerInitialLocation, Player.PlayerSize);
            Lives = 2;
            Wave = 0;
            NextWave();
        }
Пример #3
0
        public void StartGame()
        {
            GameOver = false;

            foreach (Invader invader in _invaders)
            {
                OnShipChanged(invader, false);
            }
            _invaders.Clear();

            foreach (Shot shot in _playerShots)
            {
                OnShotMoved(shot, true);
            }
            _playerShots.Clear();

            foreach (Shot shot in _invaderShots)
            {
                OnShotMoved(shot, true);
            }
            _invaderShots.Clear();

            foreach (Point star in _stars)
            {
                OnStarChanged(star, true);
            }
            _stars.Clear();
            for (int i = 0; i < InitialStarCount; i++)
            {
                AddStar();
            }

            _player = new Player(new Point(_random.Next((int)(PlayAreaSize.Width - Player.PlayerSize.Width)),
                                           (int)(PlayAreaSize.Height) - Player.PlayerSize.Height));
            OnShipChanged(_player, false);
            Lives = 2;

            Wave = 0;
            NextWave();
        }