예제 #1
0
        public void ProcessMoves()
        {
            while (_commandsQueue.Count() != 0)
            {
                var command = _commandsQueue.Dequeue();

                if (command.Direction == RelativeDirection.Forward)
                {
                    var newCoordinates = _position.ProcessMovement(command.Distance);

                    if (!_terrain.WithinPerimeter(newCoordinates))
                    {
                        _commandsQueue.Clear();
                    }
                    else
                    {
                        _position.ExecuteMovement(newCoordinates);
                    }
                }
                else
                {
                    _position.ExecuteTurn(command);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Load in a list of game commands to restore the game to a known state.
        /// </summary>
        /// <param name="commands">ReadOnlyCollection of game commands.</param>
        public void LoadGame(ReadOnlyCollection <ICommand> commands)
        {
            _commandQueue.Clear();

            foreach (var command in commands)
            {
                ProcessCommand(command.FullTextCommand);
            }
        }
예제 #3
0
        /// <summary>
        /// Closes the connection.
        /// </summary>
        public override void Close()
        {
            base.Close();
            if (!m_closing)
            {
                m_closing = true;

                BattleNetClientResources.UnregisterClient(this);

                OnDisconnected(BaseEventArgs.GetEmpty(null));

                m_queue.Clear(); // clear the outgoing command queue

                StopParsingAndListening();

                ResetConnectionState();
            }
            else
            {
                m_closing = false;
            }
        }