/// <summary> /// GUI displayed when the user is authenticated and we have an active match loaded /// </summary> private void authenticatedWithActiveMatchGUI() { GUILayout.Label("Match Status: " + currentMatch.status + ", Description: " + currentMatch.matchDescription); // is it our turn? if (currentMatch.isLocalPlayersTurn) { GUILayout.Label("It is Our Turn"); if (GUILayout.Button("Take Turn")) { GPGTurnBasedMultiplayer.takeTurn(currentMatch.matchId, getMatchDataWithNewDataAppended(), getPendingParticipantId()); currentMatch = null; } if (GUILayout.Button("Finish Match Without Data")) { GPGTurnBasedMultiplayer.finishMatchWithoutData(currentMatch.matchId); currentMatch = null; } if (GUILayout.Button("Finish Match With Data")) { var results = new List <GPGTurnBasedParticipantResult>(); // we will need to create a GPGTurnBasedParticipantResult for each player in the match // for demonstration purposes we will just set the result to Tie foreach (var player in currentMatch.players) { results.Add(new GPGTurnBasedParticipantResult(player.participantId, GPGTurnBasedParticipantResultStatus.Tie)); } GPGTurnBasedMultiplayer.finishMatchWithData(currentMatch.matchId, getMatchDataWithNewDataAppended(), results); currentMatch = null; } if (GUILayout.Button("Leave Match During Turn")) { GPGTurnBasedMultiplayer.leaveDuringTurn(currentMatch.matchId, getPendingParticipantId()); currentMatch = null; } dismissMatchGuiButton(); } else { GUILayout.Label("It is Not Our Turn"); if (GUILayout.Button("Leave Match Out of Turn")) { GPGTurnBasedMultiplayer.leaveOutOfTurn(currentMatch.matchId); currentMatch = null; } dismissMatchGuiButton(); } }
/// <summary> /// GUI displayed when the user is authenticated and we have an inactive match loaded /// </summary> private void authenticatedWithInactiveMatchGUI() { GUILayout.Label("Match Status: " + currentMatch.status + ", Description: " + currentMatch.matchDescription); // we have this check here to work around what appears to be a Play bug on Android. Sometimes it is possible to get // a match in a state where it is our turn even though the match is completed. We need to get that status properly set // to MatchCompleted so we call finishMatch to do so. if (currentMatch.isLocalPlayersTurn) { if (GUILayout.Button("Finish Match Without Data")) { GPGTurnBasedMultiplayer.finishMatchWithoutData(currentMatch.matchId); currentMatch = null; } } else { if (currentMatch.canRematch) { if (GUILayout.Button("Rematch")) { GPGTurnBasedMultiplayer.rematch(currentMatch.matchId); currentMatch = null; } } } dismissMatchGuiButton(); }
// this is only broken out due to it being present 3 times void dismissMatchGuiButton() { if (GUILayout.Button("Dismiss Match")) { GPGTurnBasedMultiplayer.dismissMatch(currentMatch.matchId); currentMatch = null; } if (GUILayout.Button("Clear Current Local Match")) { currentMatch = null; } }
/// <summary> /// GUI displayed when the user is authenticated but there is no match loaded /// </summary> private void authenticatedWithNoMatchLoadedGUI() { #if UNITY_IOS // iOS only if (GUILayout.Button("Register Device Token")) { if (NotificationServices.deviceToken != null) { GPGMultiplayer.registerDeviceToken(NotificationServices.deviceToken, false); } else { Debug.LogWarning("NotificationServices.deviceToken is null so we are not registering with Google"); } } #else // Android only if (GUILayout.Button("Check for Invites and Matches after Launch")) { GPGTurnBasedMultiplayer.checkForInvitesAndMatches(); } #endif GUILayout.Label("Match Creation and Management"); if (GUILayout.Button("Show Match Inbox")) { GPGTurnBasedMultiplayer.showInbox(); } if (GUILayout.Button("Show Player Selector")) { GPGTurnBasedMultiplayer.showPlayerSelector(1, 2); } if (GUILayout.Button("Create Match Programmatically")) { GPGTurnBasedMultiplayer.createMatchProgrammatically(1, 1, 0); } if (GUILayout.Button("Load All Matches")) { GPGTurnBasedMultiplayer.loadAllMatches(); } }