当前位置: 首页>>代码示例>>C#>>正文


C# Multiplayer.TurnBasedMatch类代码示例

本文整理汇总了C#中GooglePlayGames.BasicApi.Multiplayer.TurnBasedMatch的典型用法代码示例。如果您正苦于以下问题:C# TurnBasedMatch类的具体用法?C# TurnBasedMatch怎么用?C# TurnBasedMatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TurnBasedMatch类属于GooglePlayGames.BasicApi.Multiplayer命名空间,在下文中一共展示了TurnBasedMatch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetOpponent

 public static Participant GetOpponent(TurnBasedMatch match) {
 	foreach (Participant p in match.Participants) {
 		if (!p.ParticipantId.Equals(match.SelfParticipantId)) {
 			return p;
 		}
 	}
 	return null;
 }
开发者ID:486boy,项目名称:play-games-plugin-for-unity,代码行数:8,代码来源:Util.cs

示例2: OnMatchStarted

    protected void OnMatchStarted(bool success, TurnBasedMatch match) {
        EndStandBy();
        if (!success) {
            mErrorMessage = "There was a problem setting up the match.\nPlease try again.";
            return;
        }

        gameObject.GetComponent<PlayGui>().LaunchMatch(match);
    }
开发者ID:486boy,项目名称:play-games-plugin-for-unity,代码行数:9,代码来源:MainMenuGui.cs

示例3: OnGotMatch

 protected void OnGotMatch(TurnBasedMatch match, bool shouldAutoLaunch) {
     if (shouldAutoLaunch) {
     	// if shouldAutoLaunch is true, we know the user has indicated (via an external UI)
     	// that they wish to play this match right now, so we take the user to the
     	// game screen without further delay:
         OnMatchStarted(true, match);
     } else {
     	// if shouldAutoLaunch is false, this means it's not clear that the user
     	// wants to jump into the game right away (for example, we might have received
     	// this match from a background push notification). So, instead, we will
     	// calmly hold on to the match and show a prompt so they can decide
     	mIncomingMatch = match;
     }
 }
开发者ID:486boy,项目名称:play-games-plugin-for-unity,代码行数:14,代码来源:MainMenuGui.cs

示例4: LaunchMatch

    public void LaunchMatch(TurnBasedMatch match)
    {
        Reset();
        mMatch = match;
        MakeActive();

        if (mMatch == null) {
            throw new System.Exception("PlayGui can't be started without a match!");
        }
        try {
            // Note that mMatch.Data might be null (when we are starting a new match).
            // MatchData.MatchData() correctly deals with that and initializes a
            // brand-new match in that case.
            mMatchData = new MatchData(mMatch.Data);
        } catch (MatchData.UnsupportedMatchFormatException ex) {
            mFinalMessage = "Your game is out of date. Please update your game\n" +
                "in order to play this match.";
            Debug.LogWarning("Failed to parse board data: " + ex.Message);
            return;
        }

        // determine if I'm the 'X' or the 'O' player
        mMyMark = mMatchData.GetMyMark(match.SelfParticipantId);

        bool canPlay = (mMatch.Status == TurnBasedMatch.MatchStatus.Active &&
                mMatch.TurnStatus == TurnBasedMatch.MatchTurnStatus.MyTurn);

        if (canPlay) {
            mShowInstructions = true;
        } else {
            mFinalMessage = ExplainWhyICantPlay();
        }

        // if the match is in the completed state, acknowledge it
        if (mMatch.Status == TurnBasedMatch.MatchStatus.Complete) {
            PlayGamesPlatform.Instance.TurnBased.AcknowledgeFinished(mMatch,
                    (bool success) => {
                if (!success) {
                    Debug.LogError("Error acknowledging match finish.");
                }
            });
        }

        // set up the objects to show the match to the player
        SetupObjects(canPlay);
    }
开发者ID:damard,项目名称:Unity,代码行数:46,代码来源:PlayGui.cs

示例5: DoTbmpAckFinish

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

        if (mMatch.Status != TurnBasedMatch.MatchStatus.Complete)
        {
            mStatus = "Match is not complete";
            return;
        }

        SetStandBy("Ack'ing finished match");
        PlayGamesPlatform.Instance.TurnBased.AcknowledgeFinished(
            mMatch,
            (bool success) =>
            {
                EndStandBy();
                ShowEffect(success);
                mStatus = success ? "Successfully ack'ed finish." : "Failed to ack finish.";
                if (success)
                {
                    mMatch = null;
                    mUi = Ui.Tbmp;
                }
            });
    }
开发者ID:rida1148,项目名称:play-games-plugin-for-unity,代码行数:29,代码来源:MainGui.cs

示例6: DoTbmpCancel

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

        if (mMatch.Status != TurnBasedMatch.MatchStatus.Active)
        {
            mStatus = "Match is not active.";
            return;
        }

        SetStandBy("Cancelling match...");
        PlayGamesPlatform.Instance.TurnBased.Cancel(
            mMatch,
            (bool success) =>
            {
                EndStandBy();
                ShowEffect(success);
                mStatus = success ? "Successfully cancelled match." : "Failed to cancel match.";
                if (success)
                {
                    mMatch = null;
                    mUi = Ui.Tbmp;
                }
            });
    }
开发者ID:rida1148,项目名称:play-games-plugin-for-unity,代码行数:29,代码来源:MainGui.cs

示例7: DoTbmpAcceptFromInbox

 private void DoTbmpAcceptFromInbox()
 {
     SetStandBy("Accepting TBMP from inbox...");
     PlayGamesPlatform.Instance.TurnBased.AcceptFromInbox((bool success, TurnBasedMatch match) =>
         {
             ShowEffect(success);
             EndStandBy();
             mMatch = match;
             mStatus = success ? "Successfully accepted from inbox!" : "Failed to accept from inbox";
             if (success)
             {
                 mUi = Ui.TbmpMatch;
             }
         });
 }
开发者ID:rida1148,项目名称:play-games-plugin-for-unity,代码行数:15,代码来源:MainGui.cs

示例8: DoTbmpAcceptIncoming

    private void DoTbmpAcceptIncoming()
    {
        if (mLastInvitationId == null)
        {
            mStatus = "No incoming invitation received from listener.";
            return;
        }

        SetStandBy("Accepting TBMP invitation...");
        PlayGamesPlatform.Instance.TurnBased.AcceptInvitation(
            mLastInvitationId,
            (bool success, TurnBasedMatch match) =>
            {
                ShowEffect(success);
                EndStandBy();
                mMatch = match;
                mStatus = success ? "Successfully accepted invitation!" :
                "Failed to accept invitation";
                if (success)
                {
                    mUi = Ui.TbmpMatch;
                }
            });
    }
开发者ID:rida1148,项目名称:play-games-plugin-for-unity,代码行数:24,代码来源:MainGui.cs

示例9: AcknowledgeFinished

 public void AcknowledgeFinished(TurnBasedMatch match, Action<bool> callback)
 {
     callback = Callbacks.AsOnGameThreadCallback(callback);
     FindEqualVersionMatch(match, callback, foundMatch =>
         {
             mTurnBasedManager.ConfirmPendingCompletion(
                 foundMatch, response => callback(response.RequestSucceeded()));
         });
 }
开发者ID:Badeye,项目名称:impulse,代码行数:9,代码来源:NativeTurnBasedMultiplayerClient.cs

示例10: FindEqualVersionMatch

        private void FindEqualVersionMatch(TurnBasedMatch match, Action<bool> onFailure,
                                       Action<NativeTurnBasedMatch> onVersionMatch)
        {
            mTurnBasedManager.GetMatch(match.MatchId, response =>
                {
                    using (var foundMatch = response.Match())
                    {
                        if (foundMatch == null)
                        {
                            Logger.e(string.Format("Could not find match {0}", match.MatchId));
                            onFailure(false);
                            return;
                        }

                        if (foundMatch.Version() != match.Version)
                        {
                            Logger.e(string.Format("Attempted to update a stale version of the " +
                                    "match. Expected version was {0} but current version is {1}.",
                                    match.Version, foundMatch.Version()));
                            onFailure(false);
                            return;
                        }

                        onVersionMatch(foundMatch);
                    }
                });
        }
开发者ID:Badeye,项目名称:impulse,代码行数:27,代码来源:NativeTurnBasedMultiplayerClient.cs

示例11: DoTbmpTakeTurn

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

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

        SetStandBy("Taking turn...");
        PlayGamesPlatform.Instance.TurnBased.TakeTurn(
            mMatch,
            System.Text.ASCIIEncoding.Default.GetBytes(GenString()),
            GetNextToPlay(mMatch),
            (bool success) =>
            {
                EndStandBy();
                ShowEffect(success);
                mStatus = success ? "Successfully took turn." : "Failed to take turn.";
                if (success)
                {
                    mMatch = null;
                    mUi = Ui.Tbmp;
                }
            });
    }
开发者ID:rida1148,项目名称:play-games-plugin-for-unity,代码行数:31,代码来源:MainGui.cs

示例12: DoTbmpQuickGame

 private void DoTbmpQuickGame()
 {
     SetStandBy("Creating TBMP quick match...");
     PlayGamesPlatform.Instance.TurnBased.CreateQuickMatch(
         1,
         1,
         0,
         (bool success, TurnBasedMatch match) =>
         {
             ShowEffect(success);
             EndStandBy();
             mMatch = match;
             mStatus = success ? "Match created" : "Match creation failed";
             if (success)
             {
                 mUi = Ui.TbmpMatch;
             }
         });
 }
开发者ID:rida1148,项目名称:play-games-plugin-for-unity,代码行数:19,代码来源:MainGui.cs

示例13: Rematch

 public void Rematch(TurnBasedMatch match, Action<bool, TurnBasedMatch> callback)
 {
     callback = Callbacks.AsOnGameThreadCallback(callback);
     FindEqualVersionMatch(match, failed => callback(false, null), foundMatch =>
         {
             mTurnBasedManager.Rematch(foundMatch, BridgeMatchToUserCallback(
                 (status, m) => callback(status == UIStatus.Valid, m)));
         });
 }
开发者ID:Badeye,项目名称:impulse,代码行数:9,代码来源:NativeTurnBasedMultiplayerClient.cs

示例14: ShowIncomingMatchUi

    void ShowIncomingMatchUi()
    {
        switch (mIncomingMatch.Status) {
        case TurnBasedMatch.MatchStatus.Cancelled:
          GuiLabel (CenterLabelCfg, Util.GetOpponentName (mIncomingMatch) + " declined your invitation");
          if (GuiButton (OkButtonCfg)) {
            mIncomingMatch = null;
          }
        break;
        case TurnBasedMatch.MatchStatus.Complete:
          GuiLabel (CenterLabelCfg, "Your match with " + Util.GetOpponentName (mIncomingMatch) + " is over...");
          if (GuiButton (OkButtonCfg)) {
            TurnBasedMatch match = mIncomingMatch;
            mIncomingMatch = null;
            OnMatchStarted (true, match);
          }
        break;

        default:
          switch (mIncomingMatch.TurnStatus) {
          case TurnBasedMatch.MatchTurnStatus.MyTurn:
            GuiLabel (CenterLabelCfg, "It's your turn against " + Util.GetOpponentName (mIncomingMatch)
                  + " " + mIncomingMatch.Status + " turn = " + mIncomingMatch.TurnStatus);
            if (GuiButton (PlayButtonCfg)) {
              TurnBasedMatch match = mIncomingMatch;
              mIncomingMatch = null;
              OnMatchStarted (true, match);
            } else if (GuiButton (NotNowButtonCfg)) {
              mIncomingMatch = null;
            }
          break;
          default:
            GuiLabel (CenterLabelCfg, Util.GetOpponentName (mIncomingMatch) + " accepted your invitation");
            if (GuiButton (OkButtonCfg)) {
              mIncomingMatch = null;
            }
          break;
          }
        break;

        } // end match status
    }
开发者ID:damard,项目名称:Unity,代码行数:42,代码来源:MainMenuGui.cs

示例15: Cancel

 public void Cancel(TurnBasedMatch match, Action<bool> callback)
 {
     callback = Callbacks.AsOnGameThreadCallback(callback);
     FindEqualVersionMatch(match, callback, foundMatch =>
         {
             mTurnBasedManager.CancelMatch(foundMatch, status => callback(status > 0));
         });
 }
开发者ID:Badeye,项目名称:impulse,代码行数:8,代码来源:NativeTurnBasedMultiplayerClient.cs


注:本文中的GooglePlayGames.BasicApi.Multiplayer.TurnBasedMatch类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。