Example #1
0
        /// <summary>
        /// Processes this current round, then notifies all players of round completion.
        /// </summary>
        private void ProcessRound()
        {
            _roundProcessor.ProcessRound();

            foreach (var player in _players)
            {
                player.RoundComplete(_gameMap, _gameMap.CurrentRound);
            }

            PublishRoundComplete();
            _gameMap.CurrentRound++;
            StartNewRound();

            if (_gameMap.RegisteredPlayerEntities.Count(x => !x.Killed) < 2)
            {
                PublishGameComplete();
                return;
            }

            if (_gameMap.CurrentRound > (_gameMap.MapHeight * _gameMap.MapWidth))
            {
                PublishGameComplete();
                return;
            }

            foreach (var player in _players)
            {
                player.NewRoundStarted(_gameMap);
            }
        }
Example #2
0
        /// <summary>
        /// Processes this current round, then notifies all players of round completion.
        /// </summary>
        private void ProcessRound()
        {
            var successfulRound = _roundProcessor.ProcessRound();

            foreach (var player in _players)
            {
                player.RoundComplete(_gameMap, _gameMap.CurrentRound);
            }

            PublishRoundComplete();
            if (!successfulRound && _gameMap.Phase == 1)
            {
                _gameMap.SuccessfulFirstRound = false;
                _roundProcessor.ResetBackToStart();
                PublishFirstRoundFailed();
            }
            else
            {
                _gameMap.SuccessfulFirstRound = true;
                _gameMap.Phase = 2;
            }
            _gameMap.CurrentRound++;
            StartNewRound();

            if (_gameMap.RegisteredPlayers.Count(x => !x.Killed) <= 1)
            {
                PublishGameComplete();
                return;
            }

            if (_gameMap.CurrentRound > ((_gameMap.MapSize * _gameMap.MapSize) + 5))
            {
                PublishGameComplete();
                return;
            }

            foreach (var player in _players)
            {
                var thread = new Thread(() => player.NewRoundStarted(_gameMap));
                thread.Start();
                thread.Join();
            }
            _resetEvent.Reset();
        }