public void Authenticate(System.Action <bool> callback, bool silent)
 {
     mRealTimeClient = new DummyRealTimeMultiplayerClient();
     SceneMaster.instance.Async(() => {
         authenticated = !Input.GetKey(KeyCode.F);
         if (callback != null)
         {
             callback.Invoke(authenticated);
         }
     }, Utils.DUMMY_PLAY_GAMES_REAL_TIME_ASYNC_DELAY);
 }
Beispiel #2
0
        public IOSClient()
        {
            mCloudEncrypter = DummyEncrypter;
            if (Logger.DebugLogEnabled)
            {
                Logger.d("Note: debug logs enabled on IOSClient.");
                GPGSEnableDebugLog(true);
            }
            if (sInstance != null)
            {
                Logger.e("Second instance of IOSClient created. This is not supposed to happen " +
                         "and will likely break things.");
            }
            sInstance = this;

            mRtmpClient = new IOSRtmpClient();
            mTbmpClient = new IOSTbmpClient();
        }
Beispiel #3
0
    void Start()
    {
        RTClient = PlayGamesPlatform.Instance.RealTime;
        //lobbyGUI.SetActive (false);
        //ChangePlayerCount (0);


        PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();

        PlayGamesPlatform.InitializeInstance(config);
        PlayGamesPlatform.DebugLogEnabled = true;
        PlayGamesPlatform.Activate();

        GameObject.FindObjectOfType <MPMenu> ().GetComponent <MPMenu> ().GirisYapildiMi(Social.localUser.authenticated);
        if (Social.localUser.authenticated != true)
        {
            //Login ();
        }
    }
Beispiel #4
0
        ///<summary></summary>
        /// <seealso cref="GooglePlayGames.BasicApi.IPlayGamesClient.Authenticate"/>
        public void Authenticate(Action <bool, string> callback, bool silent)
        {
            lock (AuthStateLock)
            {
                // If the user is already authenticated, just fire the callback, we don't need
                // any additional work.
                if (mAuthState == AuthState.Authenticated)
                {
                    InvokeCallbackOnGameThread(callback, true, null);
                    return;
                }
            }

            InitializeTokenClient();

            Debug.Log("Starting Auth with token client.");
            mTokenClient.FetchTokens(silent, (int result) =>
            {
                bool succeed = result == 0 /* CommonStatusCodes.SUCCEED */;
                InitializeGameServices();
                if (succeed)
                {
                    using (var signInTasks = new AndroidJavaObject("java.util.ArrayList"))
                    {
                        if (mInvitationDelegate != null)
                        {
                            mInvitationCallback = new AndroidJavaObject(
                                "com.google.games.bridge.InvitationCallbackProxy",
                                new InvitationCallbackProxy(mInvitationDelegate));
                            using (var invitationsClient = getInvitationsClient())
                                using (var taskRegisterCallback =
                                           invitationsClient.Call <AndroidJavaObject>("registerInvitationCallback",
                                                                                      mInvitationCallback))
                                {
                                    signInTasks.Call <bool>("add", taskRegisterCallback);
                                }
                        }

                        AndroidJavaObject taskGetPlayer =
                            getPlayersClient().Call <AndroidJavaObject>("getCurrentPlayer");
                        AndroidJavaObject taskGetActivationHint =
                            getGamesClient().Call <AndroidJavaObject>("getActivationHint");
                        AndroidJavaObject taskIsCaptureSupported =
                            getVideosClient().Call <AndroidJavaObject>("isCaptureSupported");

                        if (!mConfiguration.IsHidingPopups)
                        {
                            AndroidJavaObject taskSetViewForPopups;
                            using (var popupView = AndroidHelperFragment.GetDefaultPopupView())
                            {
                                taskSetViewForPopups =
                                    getGamesClient().Call <AndroidJavaObject>("setViewForPopups", popupView);
                            }

                            signInTasks.Call <bool>("add", taskSetViewForPopups);
                        }

                        signInTasks.Call <bool>("add", taskGetPlayer);
                        signInTasks.Call <bool>("add", taskGetActivationHint);
                        signInTasks.Call <bool>("add", taskIsCaptureSupported);

                        using (var tasks = new AndroidJavaClass(TasksClassName))
                            using (var allTask = tasks.CallStatic <AndroidJavaObject>("whenAll", signInTasks))
                            {
                                AndroidTaskUtils.AddOnCompleteListener <AndroidJavaObject>(
                                    allTask,
                                    completeTask =>
                                {
                                    if (completeTask.Call <bool>("isSuccessful"))
                                    {
                                        using (var resultObject = taskGetPlayer.Call <AndroidJavaObject>("getResult"))
                                        {
                                            mUser = AndroidJavaConverter.ToPlayer(resultObject);
                                        }

                                        var account = mTokenClient.GetAccount();
                                        lock (GameServicesLock)
                                        {
                                            mSavedGameClient = new AndroidSavedGameClient(account);
                                            mEventsClient    = new AndroidEventsClient(account);
                                            bool isCaptureSupported;
                                            using (var resultObject =
                                                       taskIsCaptureSupported.Call <AndroidJavaObject>("getResult"))
                                            {
                                                isCaptureSupported = resultObject.Call <bool>("booleanValue");
                                            }

                                            mVideoClient     = new AndroidVideoClient(isCaptureSupported, account);
                                            mRealTimeClient  = new AndroidRealTimeMultiplayerClient(this, account);
                                            mTurnBasedClient = new AndroidTurnBasedMultiplayerClient(this, account);
                                            mTurnBasedClient.RegisterMatchDelegate(mConfiguration.MatchDelegate);
                                        }

                                        mAuthState = AuthState.Authenticated;
                                        InvokeCallbackOnGameThread(callback, true, "Authentication succeeded");
                                        GooglePlayGames.OurUtils.Logger.d("Authentication succeeded");
                                        try
                                        {
                                            using (var activationHint =
                                                       taskGetActivationHint.Call <AndroidJavaObject>("getResult"))
                                            {
                                                if (mInvitationDelegate != null)
                                                {
                                                    try
                                                    {
                                                        using (var invitationObject =
                                                                   activationHint.Call <AndroidJavaObject>("getParcelable",
                                                                                                           "invitation" /* Multiplayer.EXTRA_INVITATION */))
                                                        {
                                                            Invitation invitation =
                                                                AndroidJavaConverter.ToInvitation(invitationObject);
                                                            mInvitationDelegate(invitation, /* shouldAutoAccept= */
                                                                                true);
                                                        }
                                                    }
                                                    catch (Exception)
                                                    {
                                                        // handle null return
                                                    }
                                                }


                                                if (mTurnBasedClient.MatchDelegate != null)
                                                {
                                                    try
                                                    {
                                                        using (var matchObject =
                                                                   activationHint.Call <AndroidJavaObject>("getParcelable",
                                                                                                           "turn_based_match" /* Multiplayer#EXTRA_TURN_BASED_MATCH */)
                                                               )
                                                        {
                                                            TurnBasedMatch turnBasedMatch =
                                                                AndroidJavaConverter.ToTurnBasedMatch(matchObject);
                                                            mTurnBasedClient.MatchDelegate(
                                                                turnBasedMatch, /* shouldAutoLaunch= */ true);
                                                        }
                                                    }
                                                    catch (Exception)
                                                    {
                                                    }
                                                }
                                            }
                                        }
                                        catch (Exception)
                                        {
                                            // handle null return
                                        }

                                        LoadAchievements(ignore => { });
                                    }
                                    else
                                    {
                                        SignOut();
                                        InvokeCallbackOnGameThread(callback, false, "Authentication failed");
                                        GooglePlayGames.OurUtils.Logger.d("Authentication failed");
                                    }
                                }
                                    );
                            }
                    }
                }
                else
                {
                    lock (AuthStateLock)
                    {
                        if (result == 16 /* CommonStatusCodes.CANCELED */)
                        {
                            InvokeCallbackOnGameThread(callback, false, "Authentication canceled");
                            GooglePlayGames.OurUtils.Logger.d("Authentication canceled");
                        }
                        else if (result == 8 /* CommonStatusCodes.DEVELOPER_ERROR */)
                        {
                            InvokeCallbackOnGameThread(callback, false, "Authentication failed - developer error");
                            GooglePlayGames.OurUtils.Logger.d("Authentication failed - developer error");
                        }
                        else
                        {
                            InvokeCallbackOnGameThread(callback, false, "Authentication failed");
                            GooglePlayGames.OurUtils.Logger.d("Authentication failed");
                        }
                    }
                }
            });
        }
        public IOSClient() {
            mCloudEncrypter = DummyEncrypter;
            if (Logger.DebugLogEnabled) {
                Logger.d("Note: debug logs enabled on IOSClient.");
                GPGSEnableDebugLog(true);
            }
            if (sInstance != null) {
                Logger.e("Second instance of IOSClient created. This is not supposed to happen " +
                    "and will likely break things.");
            }
            sInstance = this;

            mRtmpClient = new IOSRtmpClient();
            mTbmpClient = new IOSTbmpClient();
        }
 public void SignOut()
 {
     authenticated   = false;
     mRealTimeClient = null;
 }