private void DoTbmpFinish()
    {
        if (mMatch == null)
        {
            mStatus = "No match is active.";
            return;
        }

        if (mMatch.TurnStatus != TurnBasedMatch.MatchTurnStatus.MyTurn)
        {
            mStatus = "Not my turn.";
            return;
        }

        // I win; every one else loses
        MatchOutcome outcome = new MatchOutcome();
        foreach (Participant p in mMatch.Participants)
        {
            if (p.ParticipantId.Equals(mMatch.SelfParticipantId))
            {
                outcome.SetParticipantResult(p.ParticipantId, MatchOutcome.ParticipantResult.Win, 1);
            }
            else
            {
                outcome.SetParticipantResult(p.ParticipantId, MatchOutcome.ParticipantResult.Loss, 2);
            }
        }

        SetStandBy("Finishing match...");
        PlayGamesPlatform.Instance.TurnBased.Finish(
            mMatch,
            System.Text.ASCIIEncoding.Default.GetBytes("the end!"),
            outcome,
            (bool success) =>
            {
                EndStandBy();
                ShowEffect(success);
                mStatus = success ? "Successfully finished match." : "Failed to finish match.";
                if (success)
                {
                    mMatch = null;
                    mUi = Ui.Tbmp;
                }
            });
    }
Пример #2
0
    void FinishMatch() {
        bool winnerIsMe = mMatchData.Winner == mMyMark;

        // define the match's outcome
        MatchOutcome outcome = new MatchOutcome();
        outcome.SetParticipantResult(mMatch.SelfParticipantId,
            winnerIsMe ? MatchOutcome.ParticipantResult.Win :
                MatchOutcome.ParticipantResult.Loss);
        outcome.SetParticipantResult(GetAdversaryParticipantId(),
            winnerIsMe ? MatchOutcome.ParticipantResult.Loss :
                MatchOutcome.ParticipantResult.Win);

        // finish the match
        SetStandBy("Sending...");
        PlayGamesPlatform.Instance.TurnBased.Finish(mMatch.MatchId, mMatchData.ToBytes(),
                    outcome, (bool success) => {
            EndStandBy();
            mFinalMessage = success ? (winnerIsMe ? "YOU WON!" : "YOU LOST!") :
                "ERROR finishing match.";
        });
    }