Example #1
0
 public KickPlayerPoll(NetworkCommunicator playerPeer, bool banPlayer)
 {
     this.PlayerPeer = playerPeer;
     this.BanPlayer  = banPlayer;
 }
 public UpdateSelectedTroopIndex(NetworkCommunicator peer, int selectedTroopIndex)
 {
     this.Peer = peer;
     this.SelectedTroopIndex = selectedTroopIndex;
 }
Example #3
0
 void IUdpNetworkHandler.HandleEarlyPlayerDisconnect(
     NetworkCommunicator networkPeer)
 {
     this.HandleEarlyPlayerDisconnect(networkPeer);
 }
Example #4
0
 void IUdpNetworkHandler.HandlePlayerDisconnect(NetworkCommunicator networkPeer) => this.HandlePlayerDisconnect(networkPeer);
Example #5
0
 void IUdpNetworkHandler.HandleLateNewClientAfterLoadingFinished(
     NetworkCommunicator networkPeer)
 {
     this.HandleLateNewClientAfterLoadingFinished(networkPeer);
 }
Example #6
0
 void IUdpNetworkHandler.HandleLateNewClientAfterSynchronized(
     NetworkCommunicator networkPeer)
 {
     this.HandleLateNewClientAfterSynchronized(networkPeer);
 }
Example #7
0
 protected virtual void HandleLateNewClientAfterSynchronized(NetworkCommunicator networkPeer)
 {
 }
Example #8
0
 protected virtual void HandlePlayerDisconnect(NetworkCommunicator networkPeer)
 {
 }
Example #9
0
 public RemoveAgentVisualsForPeer(NetworkCommunicator peer) => this.Peer = peer;
Example #10
0
 protected virtual void HandleLateNewClientAfterLoadingFinished(NetworkCommunicator networkPeer)
 {
 }
Example #11
0
 public AddPeerComponent(NetworkCommunicator peer, uint componentId)
 {
     this.Peer        = peer;
     this.ComponentId = componentId;
 }
 public CreateBanner(NetworkCommunicator peer, string bannerCode)
 {
     this.Peer       = peer;
     this.BannerCode = bannerCode;
 }
Example #13
0
        private void ClientGameLoop(object client)
        {
            NetworkCommunicator networkCommunicator = (NetworkCommunicator)client;
            ManualResetEvent    sentDataThisTurn    = new ManualResetEvent(false);
            ManualResetEvent    endOfTurnWait       = new ManualResetEvent(false);

            try
            {
                string data = string.Empty;

                _playersThatSentDataThisTurnList.Add(sentDataThisTurn);
                _endOfTurnWaitList.Add(endOfTurnWait);
                _currentTurnClientActions.Add(new PlayerAction(networkCommunicator.RemoteEndPoint.ToString(), MessageConstants.PlayerActionNone));

                _log.InfoFormat("Client {0} connected running on thread: {1}, waiting for start game / 1st turn data", networkCommunicator.RemoteEndPoint, Thread.CurrentThread.ManagedThreadId);
                data = networkCommunicator.ReceiveData();
                bool readFromClient = false;

                if (data == MessageConstants.StartGame)
                {
                    readFromClient = true;
                    RunGame();
                    foreach (NetworkCommunicator clientPlayer in _players)
                    {
                        clientPlayer.SendData(MessageConstants.GameStarting);
                    }
                    _completeGameState.StartNewGame(_currentTurnClientActions);
                }

                // Loop to receive all the data sent by the client.
                // this is now the main game loop for the game - 1 thread per client
                bool gameIsOn = true;
                while (gameIsOn) //issue [B.2.3] of the design document
                {
                    if (readFromClient)
                    {
                        data = networkCommunicator.ReceiveData();
                    }
                    else
                    {
                        readFromClient = true;
                    }

                    foreach (PlayerAction action in _currentTurnClientActions)
                    {
                        if (action.PlayerID == networkCommunicator.RemoteEndPoint.ToString())
                        {
                            action.Action = data;
                        }
                    }
                    sentDataThisTurn.Set();

                    _gameStateProcessed.WaitOne();

                    networkCommunicator.SendData(_completeGameState.ToString());
                    endOfTurnWait.Set();
                    WaitHandle.WaitAll(_endOfTurnWaitArray); //issue [B.2.3] of the design document
                    _gameStateProcessed.Reset();
                }
            }
            catch (Exception ex)
            {
                ErrorUtil.WriteError(ex);
                throw;
            }
            finally
            {
                sentDataThisTurn.Close();
                endOfTurnWait.Close();
                networkCommunicator.Dispose();
            }
        }
Example #14
0
 public SetAgentPeer(Agent agent, NetworkCommunicator peer)
 {
     this.Agent = agent;
     this.Peer  = peer;
 }
 public AssignFormationToPlayer(NetworkCommunicator peer, FormationClass formationClass)
 {
     this.Peer           = peer;
     this.FormationClass = formationClass;
 }