コード例 #1
0
            public InternalGKMatchmakerViewControllerDelegateImpl(GCRealTimeMultiplayerClient client, IRealTimeMultiplayerListener listener)
            {
                Util.NullArgumentTest(client);

                this.mClient   = client;
                this.mListener = listener;
            }
コード例 #2
0
        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);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
 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));
 }
コード例 #6
0
 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));
 }
コード例 #7
0
        private void SetupCurrentMatchAndListener(GKMatch match, IRealTimeMultiplayerListener listener)
        {
            mCurrentMatch    = match;
            mCurrentListener = listener;

            if (mCurrentMatch != null)
            {
                mCurrentMatch.Delegate = new InternalGKMatchDelegateImpl(this);
            }
        }
コード例 #8
0
        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);
                    });
                });
            }
        }
コード例 #9
0
        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);
                    });
                });
            }
        }
コード例 #10
0
        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;
            }
        }
コード例 #11
0
 public void ShowInvitationsUI(IRealTimeMultiplayerListener listener)
 {
     Debug.LogWarning(mUnavailableMessage);
 }
コード例 #12
0
 public void CreateWithMatchmakerUI(MatchRequest request, IRealTimeMultiplayerListener listener)
 {
     Debug.LogWarning(mUnavailableMessage);
 }
コード例 #13
0
 public void AcceptInvitation(Invitation invitation, bool showWaitingRoomUI, IRealTimeMultiplayerListener listener)
 {
     Debug.LogWarning(mUnavailableMessage);
 }
コード例 #14
0
 public void ShowInvitationsUI(IRealTimeMultiplayerListener listener)
 {
     Debug.Log("ShowInvitationsUI is not available on Game Center platform.");
 }
コード例 #15
0
 internal GPGRealTimeMultiplayerListener(IRealTimeMultiplayerListener listener, bool programmaticMatchmaking)
 {
     this.listener = listener;
     this.isProgrammaticMatchmaking = programmaticMatchmaking;
 }
コード例 #16
0
 public void ShowInvitationsUI(IRealTimeMultiplayerListener listener)
 {
     PlayGamesPlatform.Instance.RealTime.AcceptFromInbox(new GPGRealTimeMultiplayerListener(listener, false));
 }