• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Multiplayer.TurnBasedMatch类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: LeaveDuringTurn

 public void LeaveDuringTurn(TurnBasedMatch match, string pendingParticipantId,
                         Action<bool> callback)
 {
     callback = Callbacks.AsOnGameThreadCallback(callback);
     FindEqualVersionMatchWithParticipant(match, pendingParticipantId, callback,
         (pendingParticipant, foundMatch) =>
         {
             mTurnBasedManager.LeaveDuringMyTurn(foundMatch, pendingParticipant,
                 status => callback(status > 0));
         });
 }
开发者ID:Badeye,项目名称:impulse,代码行数:11,代码来源:NativeTurnBasedMultiplayerClient.cs


示例17: Leave

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


示例18: DoTbmpFinish

    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;
                }
            });
    }
开发者ID:rida1148,项目名称:play-games-plugin-for-unity,代码行数:45,代码来源:MainGui.cs


示例19: OnMatchFromNotification

 private void OnMatchFromNotification(TurnBasedMatch match, bool fromNotification)
 {
     if (fromNotification)
     {
         mUi = Ui.TbmpMatch;
         mMatch = match;
         mStatus = "Got match from notification! " + match;
     }
     else
     {
         mStatus = "Got match a update not from notification.";
     }
 }
开发者ID:rida1148,项目名称:play-games-plugin-for-unity,代码行数:13,代码来源:MainGui.cs


示例20: DoTbmpLeaveDuringTurn

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

        if (mMatch.TurnStatus != TurnBasedMatch.MatchTurnStatus.MyTurn)
        {
            mStatus = "It's not my turn.";
            return;
        }

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Granados.BigInteger类代码示例发布时间:2022-05-26
下一篇:
C# Protobuf.CodedOutputStream类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap