public void RegisterMatchDelegate(MatchDelegate del) { // Create and register a default local player listener if needed. if (mLocalPlayerListener == null) { mLocalPlayerListener = new InternalGKLocalPlayerListenerImpl() { CloseAndResetMatchmakerVC = () => { if (mCurrentMatchmakerVC != null) { mCurrentMatchmakerVC.DismissViewController(true, null); mCurrentMatchmakerVC = null; } } }; GKLocalPlayer.LocalPlayer.RegisterListener(mLocalPlayerListener); } mLocalPlayerListener.MatchDelegate = del; }
public void CreateWithMatchmakerUI(MatchRequest request, Action cancelCallback, Action <string> errorCallback) { Util.NullArgumentTest(request); if (mCurrentMatchmakerVC != null) { Debug.Log("Ignoring CreateWithMatchmakerUI call because another matchmaker UI is being shown."); return; } // Create a new TBM VC. var vc = InteropObjectFactory <GKTBMVC> .Create( () => { using (var gkReq = request.ToGKMatchRequest()) return(new GKTBMVC(gkReq)); }, viewController => { return(viewController.ToPointer()); }); // This VC is not showing existing matches. vc.ShowExistingMatches = false; // Create a delegate for the TBM VC. vc.TurnBasedMatchmakerDelegate = new InternalGKTBMVCDelegateImpl() { CancelCallback = cancelCallback, ErrorCallback = errorCallback, ResetMatchmakerVC = () => mCurrentMatchmakerVC = null }; // Store the VC ref. mCurrentMatchmakerVC = vc; // Now show the VC. using (var unityVC = UIViewController.UnityGetGLViewController()) unityVC.PresentViewController(vc, true, null); }
public void ShowMatchesUI() { if (mCurrentMatchmakerVC != null) { Debug.Log("Ignoring CreateWithMatchmakerUI call because another matchmaker UI is being shown."); return; } // Create a dummy request with the widest range of players possible. var gkRequest = new GKMatchRequest(); gkRequest.MinPlayers = 2; gkRequest.MaxPlayers = GKMatchRequest.MaxPlayersAllowedForMatchType(GKMatchRequest.GKMatchType.TurnBased); // Create a new TBM VC with the dummy request. var vc = InteropObjectFactory <GKTBMVC> .Create( () => new GKTBMVC(gkRequest), viewController => viewController.ToPointer()); // This VC should show existing matches. vc.ShowExistingMatches = true; // Create a delegate for the TBM VC with no callbacks. // The delegate is necessary so the VC can be closed. vc.TurnBasedMatchmakerDelegate = new InternalGKTBMVCDelegateImpl() { CancelCallback = null, ErrorCallback = null, ResetMatchmakerVC = () => mCurrentMatchmakerVC = null }; // Store the VC ref. mCurrentMatchmakerVC = vc; // Now show the VC. using (var unityVC = UIViewController.UnityGetGLViewController()) unityVC.PresentViewController(vc, true, null); }