本文整理汇总了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;
}
示例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);
}
示例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;
}
}
示例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);
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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()));
});
}
示例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);
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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)));
});
}
示例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
}
示例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));
});
}