Esempio n. 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
         });
     }
 }
Esempio n. 2
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);
                }
            }
        }