Example #1
0
 private void OnEoTReceived(int connection, EndOfTurnStateMessage msg)
 {
     if (eotReadyCheck.PlayerNotifiedReady(connection, true, msg))
     {
         EndOfTurnState hostEoT   = eotReadyCheck.GetHostData <EndOfTurnStateMessage>().state;
         EndOfTurnState clientEoT = eotReadyCheck.GetClientData <EndOfTurnStateMessage>().state;
         eotReadyCheck.Clear();
         ServerEndOfTurnState serverResponse = ServerEndOfTurnState.Error;
         if (hostEoT == EndOfTurnState.Error || clientEoT == EndOfTurnState.Error)
         {
             serverResponse = ServerEndOfTurnState.Error;
         }
         else if (hostEoT == EndOfTurnState.Forfeit && clientEoT == EndOfTurnState.Forfeit)
         {
             serverResponse = ServerEndOfTurnState.Tie;
         }
         else if (hostEoT == EndOfTurnState.Forfeit)
         {
             serverResponse = ServerEndOfTurnState.ClientWin;
         }
         else if (clientEoT == EndOfTurnState.Forfeit)
         {
             serverResponse = ServerEndOfTurnState.HostWin;
         }
         else if (hostEoT == EndOfTurnState.Undecided && clientEoT == EndOfTurnState.Undecided)
         {
             serverResponse = ServerEndOfTurnState.Undecided;
         }
         else if (hostEoT == EndOfTurnState.Tie && clientEoT == EndOfTurnState.Tie)
         {
             serverResponse = ServerEndOfTurnState.Tie;
         }
         else if (hostEoT == EndOfTurnState.Win && clientEoT == EndOfTurnState.Loss)
         {
             serverResponse = ServerEndOfTurnState.HostWin;
         }
         else if (hostEoT == EndOfTurnState.Loss && clientEoT == EndOfTurnState.Win)
         {
             serverResponse = ServerEndOfTurnState.ClientWin;
         }
         else
         {
             serverResponse = ServerEndOfTurnState.Mismatch;
         }
         NetworkTracker.ServerSendEoT(new ServerEndOfTurnStateMessage()
         {
             state = serverResponse
         });
     }
 }
Example #2
0
        private void OnReceivedNotice(int connectionID, NetworkPlayerReadyNotice notice)
        {
            bool allReady = readyCheck.PlayerNotifiedReady(connectionID, notice.ready);

            if (allReady)
            {
                readyCheck.Clear();
                onLobbyInitialized.Send();
                NetworkTracker.ServerSendLobbyInitAllReady();
            }
        }
Example #3
0
 private void OnReceiveReady(int connectionID, NetworkPlayerReadyNotice ready)
 {
     if (info.IsConnected(connectionID))
     {
         if (readyToPlay.PlayerNotifiedReady(connectionID, ready.ready))
         {
             readyToPlay.Clear();
             NetworkTracker.ServerSendLoadingExit();
         }
     }
 }
Example #4
0
        //private void CheckServerConnection() {
        //    if(info.Connection.State != (int)ServerConnectionState.Connected) {
        //        gameStates.Clear();
        //    }
        //}

        private void OnReceiveGameState(int connectionID, LoadingGameStateMessage msg)
        {
            if (info.IsConnected(connectionID))
            {
                if (gameStateRefresh.PlayerNotifiedReady(connectionID, true, msg))
                {
                    LoadingGameStateMessage hostGS   = gameStateRefresh.GetHostData <LoadingGameStateMessage>();
                    LoadingGameStateMessage clientGS = gameStateRefresh.GetClientData <LoadingGameStateMessage>();
                    LoadingGameStateMessage sendBackGS;
                    if (hostGS.hasState)
                    {
                        sendBackGS = hostGS;
                    }
                    else
                    {
                        sendBackGS = clientGS;
                    }
                    gameStateRefresh.Clear();
                    NetworkTracker.ServerSendLoadingGameState(sendBackGS);
                }
            }
        }
        private void ReceivedReady(int connectionID, NetworkPlayerReadyNotice notice)
        {
            bool allReady = readyChecker.PlayerNotifiedReady(connectionID, notice.ready);

            if (info.IsConnected(connectionID))
            {
                NetworkTracker.ServerSendLobbyReadyRelay(info.OtherConnectionID(connectionID), notice);
            }

            if (allReady)
            {
                readyChecker.Clear();
                NetworkTracker.ServerSendLobbyExitMessage(new LobbyExitMessage()
                {
                    valid           = LobbyInValidExitState(),
                    modName         = pickedMod,
                    turnOrderChoice = pickedTurnOrder,
                });
            }
        }