Пример #1
0
        public void EndMatch(int localScore, int remoteScore)
        {
            switch (m_state)
            {
            case MatchRoomState.MyTurn:
            case MatchRoomState.RemoteTurn:
                var myID     = PlatformManager.MyID.ToString();
                var remoteID = m_remotePlayer.ID.ToString();
                var rankings = new Dictionary <string, int>();
                if (localScore > remoteScore)
                {
                    rankings[myID]     = 1;
                    rankings[remoteID] = 2;
                }
                else if (localScore < remoteScore)
                {
                    rankings[myID]     = 2;
                    rankings[remoteID] = 1;
                }
                else
                {
                    rankings[myID]     = 1;
                    rankings[remoteID] = 1;
                }

                // since there is no secure server to simulate the game and report
                // verifiable results, each client needs to independently report their
                // results for the service to compate for inconsistencies
                Matchmaking.ReportResultsInsecure(m_matchRoom, rankings)
                .OnComplete(GenericErrorCheckCallback);
                break;
            }

            TransitionToState(MatchRoomState.None);
        }
Пример #2
0
        void requestReportResults()
        {
            switch (currentState)
            {
            case states.NOT_INIT:
                printOutputLine("The app has not initialized properly and we don't know your userID.");
                break;

            case states.IDLE:
            case states.REQUEST_FIND:
            case states.FINDING_ROOM:
            case states.REQUEST_JOIN:
            case states.REQUEST_CREATE:
            case states.REQUEST_LEAVE:
                printOutputLine("You need to be in a room with another player to report results on a rated match.");
                break;

            case states.IN_EMPTY_ROOM:
            case states.IN_FULL_ROOM:
                if (ratedMatchStarted)
                {
                    printOutputLine("Submitting rated match results.");

                    Dictionary <string, int> results = new Dictionary <string, int>();
                    results.Add(localUser.ID.ToString(), 1);
                    results.Add(remoteUser.ID.ToString(), 2);

                    Matchmaking.ReportResultsInsecure(currentRoom.ID, results).OnComplete(reportResultsResponse);
                }
                else
                {
                    printOutputLine("You can't report results unless you've already started a rated match");
                }
                break;

            default:
                printOutputLine("You have hit an unknown state.");
                break;
            }
        }