public void Finish(GooglePlayGames.BasicApi.Multiplayer.TurnBasedMatch match, byte[] data, MatchOutcome outcome, Action <bool> callback)
 {
     callback = Callbacks.AsOnGameThreadCallback(callback);
     FindEqualVersionMatch(match, callback, delegate(NativeTurnBasedMatch foundMatch)
     {
         GooglePlayGames.Native.PInvoke.ParticipantResults participantResults = foundMatch.Results();
         foreach (string participantId in outcome.ParticipantIds)
         {
             Types.MatchResult matchResult = ResultToMatchResult(outcome.GetResultFor(participantId));
             uint placementFor             = outcome.GetPlacementFor(participantId);
             if (participantResults.HasResultsForParticipant(participantId))
             {
                 Types.MatchResult matchResult2 = participantResults.ResultsForParticipant(participantId);
                 uint num = participantResults.PlacingForParticipant(participantId);
                 if (matchResult != matchResult2 || placementFor != num)
                 {
                     Logger.e($"Attempted to override existing results for participant {participantId}: Placing {num}, Result {matchResult2}");
                     callback(false);
                     return;
                 }
             }
             else
             {
                 GooglePlayGames.Native.PInvoke.ParticipantResults participantResults2 = participantResults;
                 participantResults = participantResults2.WithResult(participantId, placementFor, matchResult);
                 participantResults2.Dispose();
             }
         }
         mTurnBasedManager.FinishMatchDuringMyTurn(foundMatch, data, participantResults, delegate(TurnBasedManager.TurnBasedMatchResponse response)
         {
             callback(response.RequestSucceeded());
         });
     });
 }
示例#2
0
        public void Finish(TurnBasedMatch match, byte[] data, MatchOutcome outcome,
                           Action <bool> callback)
        {
            callback = Callbacks.AsOnGameThreadCallback(callback);
            FindEqualVersionMatch(match, callback, foundMatch =>
            {
                ParticipantResults results = foundMatch.Results();

                foreach (string participantId in outcome.ParticipantIds)
                {
                    Types.MatchResult matchResult =
                        ResultToMatchResult(outcome.GetResultFor(participantId));
                    uint placing = outcome.GetPlacementFor(participantId);

                    if (results.HasResultsForParticipant(participantId))
                    {
                        // If the match already has results for this participant, make sure that they're
                        // consistent with what's already there.
                        var existingResults = results.ResultsForParticipant(participantId);
                        var existingPlacing = results.PlacingForParticipant(participantId);

                        if (matchResult != existingResults || placing != existingPlacing)
                        {
                            Logger.e(string.Format("Attempted to override existing results for " +
                                                   "participant {0}: Placing {1}, Result {2}",
                                                   participantId, existingPlacing, existingResults));
                            callback(false);
                            return;
                        }
                    }
                    else
                    {
                        // Otherwise, get updated results and dispose of the old ones.
                        var oldResults = results;
                        results        = oldResults.WithResult(participantId, placing, matchResult);
                        oldResults.Dispose();
                    }
                }

                mTurnBasedManager.FinishMatchDuringMyTurn(foundMatch, data, results,
                                                          response => callback(response.RequestSucceeded()));
            });
        }