public InternalGKMatchmakerViewControllerDelegateImpl(GCRealTimeMultiplayerClient client, IRealTimeMultiplayerListener listener) { Util.NullArgumentTest(client); this.mClient = client; this.mListener = listener; }
public void CreateWithMatchmakerUI(MatchRequest request, IRealTimeMultiplayerListener listener) { Util.NullArgumentTest(request); Util.NullArgumentTest(listener); if (mCurrentMatchmakerVC != null) { Debug.Log("Ignoring CreateWithMatchmakerUI call because another matchmaker UI is being shown."); return; } // Create a new GKMatchmakerViewController. var vc = InteropObjectFactory <GKMatchmakerViewController> .Create( () => { using (var gkReq = request.ToGKMatchRequest()) return(new GKMatchmakerViewController(gkReq)); }, viewController => { return(viewController.ToPointer()); }); // Create a delgate for the vc. vc.MatchmakerDelegate = new InternalGKMatchmakerViewControllerDelegateImpl(this, listener); // Store the VC ref. mCurrentMatchmakerVC = vc; // Now show the VC. using (var unityVC = UIViewController.UnityGetGLViewController()) unityVC.PresentViewController(vc, true, null); }
public void AcceptInvitation(Invitation invitation, bool showWaitingRoomUI, IRealTimeMultiplayerListener listener) { Util.NullArgumentTest(invitation); Util.NullArgumentTest(listener); PlayGamesPlatform.Instance.RealTime.AcceptInvitation(invitation.GPGS_Invitation.InvitationId, new GPGRealTimeMultiplayerListener(listener, !showWaitingRoomUI)); }
private static void ReportRoomSetupProgress(IRealTimeMultiplayerListener listener, GKMatch match, NSError error, bool programmaticMatchmaking = false) { if (listener == null) { return; } // Setup failed. if (match == null || error != null) { listener.OnRoomConnected(false); return; } // Setup succeeded or is progressing. float progress; bool completed = IsRoomSetupComplete(match, out progress); // On progress. listener.OnRoomSetupProgress(progress); // Connected. if (completed) { // Programmatic matchmaking has finished. if (programmaticMatchmaking) { GKMatchmaker.SharedMatchmaker().FinishMatchmakingForMatch(match); } listener.OnRoomConnected(true); } }
public void CreateWithMatchmakerUI(MatchRequest request, IRealTimeMultiplayerListener listener) { PlayGamesPlatform.Instance.RealTime.CreateWithInvitationScreen( request.MinPlayers - 1, request.MaxPlayers - 1, (uint)GPGTypeConverter.ToGPGSVariant(request.Variant, MatchType.RealTime), new GPGRealTimeMultiplayerListener(listener, false)); }
public void CreateQuickMatch(MatchRequest request, IRealTimeMultiplayerListener listener) { PlayGamesPlatform.Instance.RealTime.CreateQuickGame( request.MinPlayers - 1, request.MaxPlayers - 1, (uint)GPGTypeConverter.ToGPGSVariant(request.Variant, MatchType.RealTime), new GPGRealTimeMultiplayerListener(listener, true)); }
private void SetupCurrentMatchAndListener(GKMatch match, IRealTimeMultiplayerListener listener) { mCurrentMatch = match; mCurrentListener = listener; if (mCurrentMatch != null) { mCurrentMatch.Delegate = new InternalGKMatchDelegateImpl(this); } }
public void AcceptInvitation(Invitation invitation, bool showWaitingRoomUI, IRealTimeMultiplayerListener listener) { Util.NullArgumentTest(invitation); Util.NullArgumentTest(listener); if (showWaitingRoomUI) { // Close the current matchmakerVC if any. if (mCurrentMatchmakerVC != null) { mCurrentMatchmakerVC.DismissViewController(true, null); mCurrentMatchmakerVC = null; } // Create a new GKMatchmakerViewController from the invitation. var vc = InteropObjectFactory <GKMatchmakerViewController> .Create( () => new GKMatchmakerViewController(invitation.GK_Invite), viewController => viewController.ToPointer() ); // Create a delgate for the vc. vc.MatchmakerDelegate = new InternalGKMatchmakerViewControllerDelegateImpl(this, listener); // Store the VC ref. mCurrentMatchmakerVC = vc; // Now show the VC. using (var unityVC = UIViewController.UnityGetGLViewController()) unityVC.PresentViewController(vc, true, null); } else { // Create a GKMatch from the invitation without any UI. GKMatchmaker.SharedMatchmaker().MatchForInvite(invitation.GK_Invite, (gkMatch, nsError) => { // If new match is created successfully, store it and the given listener. if (gkMatch != null) { SetupCurrentMatchAndListener(gkMatch, listener); } RuntimeHelper.RunOnMainThread(() => { ReportRoomSetupProgress(listener, gkMatch, nsError); }); }); } }
public void CreateQuickMatch(MatchRequest request, IRealTimeMultiplayerListener listener) { Util.NullArgumentTest(request); Util.NullArgumentTest(listener); using (var gkReq = request.ToGKMatchRequest()) { GKMatchmaker.SharedMatchmaker().FindMatchForRequest(gkReq, (gkMatch, nsError) => { // If new match is created successfully, store it and the given listener. if (gkMatch != null) { SetupCurrentMatchAndListener(gkMatch, listener); } RuntimeHelper.RunOnMainThread(() => { ReportRoomSetupProgress(listener, gkMatch, nsError); }); }); } }
public void LeaveRoom() { if (mCurrentMatch != null) { // Disconnect the match. mCurrentMatch.Disconnect(); // Nil out the delegate as recommended by GameKit. // https://developer.apple.com/documentation/gamekit/gkmatch?language=objc mCurrentMatch.Delegate = null; if (mCurrentListener != null) { mCurrentListener.OnLeftRoom(); } // Reset current match and listener. mCurrentMatch.Dispose(); mCurrentMatch = null; mCurrentListener = null; } }
public void ShowInvitationsUI(IRealTimeMultiplayerListener listener) { Debug.LogWarning(mUnavailableMessage); }
public void CreateWithMatchmakerUI(MatchRequest request, IRealTimeMultiplayerListener listener) { Debug.LogWarning(mUnavailableMessage); }
public void AcceptInvitation(Invitation invitation, bool showWaitingRoomUI, IRealTimeMultiplayerListener listener) { Debug.LogWarning(mUnavailableMessage); }
public void ShowInvitationsUI(IRealTimeMultiplayerListener listener) { Debug.Log("ShowInvitationsUI is not available on Game Center platform."); }
internal GPGRealTimeMultiplayerListener(IRealTimeMultiplayerListener listener, bool programmaticMatchmaking) { this.listener = listener; this.isProgrammaticMatchmaking = programmaticMatchmaking; }
public void ShowInvitationsUI(IRealTimeMultiplayerListener listener) { PlayGamesPlatform.Instance.RealTime.AcceptFromInbox(new GPGRealTimeMultiplayerListener(listener, false)); }