예제 #1
0
        /// <summary>
        /// Signs in to Apple Game Center.
        /// </summary>
        /// <param name="autoCloudLoad">
        /// Whether or not cloud data should be loaded automatically when the user is successfully signed in.
        /// Ignored if Cloud Saving is deactivated or the user fails to sign in.
        /// </param>
        /// <param name='callback'>
        /// The callback to call when authentication finishes. It will be called
        /// with <c>true</c> if authentication was successful, <c>false</c> otherwise.
        /// </param>
        public override void SignIn(bool autoCloudLoad = true, UnityAction <bool> callback = null)
        {
            if (isSigningIn)
            {
                return;
            }

            isSigningIn = true;
            if (IsSignedIn)
            {
#if CLOUDONCE_DEBUG
                Debug.Log("Already signed in to Apple Game Center." +
                          " If you want to change the user, that must be done from the iOS Settings menu.");
#endif
                CloudOnceUtils.SafeInvoke(callback, true);
                if (CloudSaveEnabled && autoCloudLoad)
                {
                    var iCloudWrapper = (iOSCloudSaveWrapper)Storage;
                    iCloudWrapper.Load();
                }

                isSigningIn = false;
                return;
            }

            Social.localUser.Authenticate(
                success =>
            {
                if (success)
                {
#if CLOUDONCE_DEBUG
                    Debug.Log("Successfully signed in to Apple Game Center.");
#endif
                    cloudOnceEvents.RaiseOnSignedInChanged(true);
                    cloudOnceEvents.RaiseOnPlayerImageDownloaded(Social.localUser.image);
                    UpdateAchievementsData();
                }
                else
                {
#if CLOUDONCE_DEBUG
                    Debug.LogWarning("Failed to sign in to Apple Game Center.");
#endif
                    cloudOnceEvents.RaiseOnSignInFailed();
                }

                if (CloudSaveEnabled && autoCloudLoad)
                {
                    var iCloudWrapper = (iOSCloudSaveWrapper)Storage;
                    iCloudWrapper.Load();
                }

                CloudOnceUtils.SafeInvoke(callback, success);
                isSigningIn = false;
            });
        }
예제 #2
0
        private void OnSignedInStateChangedEvent(bool signedIn)
        {
            if (signedIn)
            {
#if CLOUDONCE_DEBUG
                Debug.Log("Signed in to Amazon GameCircle.");
#endif
                if (CloudSaveInitialized && cloudSaveEnabled && autoLoadOnSignInEnabled)
                {
                    Cloud.Storage.Load();
                }

                AGSPlayerClient.RequestLocalPlayer();
                UpdateAchievementsData();
            }
            else
            {
#if CLOUDONCE_DEBUG
                Debug.Log("Signed out of Amazon GameCircle.");
#endif
            }

            cloudOnceEvents.RaiseOnSignedInChanged(signedIn);
        }
예제 #3
0
 /// <summary>
 /// Sets <see cref="IsGuestUserDefault"/> to <c>true</c> and raises the <see cref="CloudOnceEvents.OnSignedInChanged"/> event.
 /// </summary>
 public void ActivateGuestUserMode()
 {
     IsGuestUserDefault = true;
     cloudOnceEvents.RaiseOnSignedInChanged(false);
 }