/// <summary> /// Raises the <see cref="OnCloudLoadComplete"/> event. /// </summary> /// <param name="success">If the load was successful or not.</param> public void RaiseOnCloudLoadComplete(bool success) { #if CO_DEBUG Debug.Log("OnCloudLoadComplete: " + (success ? "Cloud load was successful." : "Cloud load failed.")); #endif CloudOnceUtils.SafeInvoke(OnCloudLoadComplete, success); }
/// <summary> /// Raises the <see cref="OnNewCloudValues"/> event. /// </summary> /// <param name="changedKeys">A <see cref="string"/> array of the changed interal IDs.</param> public void RaiseOnNewCloudValues(string[] changedKeys) { #if CLOUDONCE_DEBUG Debug.Log("OnNewCloudValues: " + changedKeys.Length + " values have changed."); #endif CloudOnceUtils.SafeInvoke(OnNewCloudValues, changedKeys); }
/// <summary> /// Raises the <see cref="OnPlayerImageDownloaded"/> event. /// </summary> public void RaiseOnPlayerImageDownloaded(Texture2D playerImage) { #if CLOUDONCE_DEBUG Debug.Log("OnPlayerImageDownloaded"); #endif CloudOnceUtils.SafeInvoke(OnPlayerImageDownloaded, playerImage); }
/// <summary> /// Raises the <see cref="OnSignInFailed"/> event. /// </summary> public void RaiseOnSignInFailed() { #if CLOUDONCE_DEBUG Debug.Log("OnSignInFailed"); #endif CloudOnceUtils.SafeInvoke(OnSignInFailed); }
/// <summary> /// Raises the <see cref="OnCloudSaveComplete"/> event. /// </summary> /// <param name="success">If the save was successful or not.</param> public void RaiseOnCloudSaveComplete(bool success) { #if CLOUDONCE_DEBUG Debug.Log("OnCloudSaveComplete: " + (success ? "Cloud save was successful." : "Cloud save failed.")); #endif CloudOnceUtils.SafeInvoke(OnCloudSaveComplete, success); }
private static void ReportError(string errorMessage, Action <CloudRequestResult <bool> > callbackAction) { #if CO_DEBUG Debug.LogWarning(errorMessage); #endif CloudOnceUtils.SafeInvoke(callbackAction, new CloudRequestResult <bool>(false, errorMessage)); }
/// <summary> /// Raises the <see cref="OnInitializeComplete"/> event. /// </summary> public void RaiseOnInitializeComplete() { #if CLOUDONCE_DEBUG Debug.Log("OnInitializeComplete"); #endif CloudOnceUtils.SafeInvoke(OnInitializeComplete); }
/// <summary> /// Raises the <see cref="OnSignedInChanged"/> event. /// </summary> public void RaiseOnSignedInChanged(bool isSignedIn) { #if CLOUDONCE_DEBUG Debug.Log("OnSignedInChanged: " + (isSignedIn ? "Signed In" : "Signed Out")); #endif CloudOnceUtils.SafeInvoke(OnSignedInChanged, isSignedIn); }
/// <summary> /// Dummy SignIn method. /// </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) { CloudOnceUtils.SafeInvoke(callback, false); if (autoCloudLoad) { cloudOnceEvents.RaiseOnCloudLoadComplete(false); } }
/// <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; }); }
/// <summary> /// Load the user profiles accociated with the given array of user IDs. /// </summary> /// <param name="userIDs">The users to retrieve profiles for.</param> /// <param name="callback">Callback to handle the user profiles.</param> public override void LoadUsers(string[] userIDs, Action <IUserProfile[]> callback) { var profiles = new IUserProfile[userIDs.Length]; for (var i = 0; i < profiles.Length; i++) { profiles[i] = new TestUserProfile(); } CloudOnceUtils.SafeInvoke(callback, profiles); }
/// <summary> /// Signs in to Google Play Game Services. /// </summary> /// <param name="autoCloudLoad"> /// Whether or not cloud data should be loaded automatically if 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 (!IsGpgsInitialized) { Debug.LogWarning("SignIn called, but Google Play Game Services has not been initialized. Ignoring call."); CloudOnceUtils.SafeInvoke(callback, false); return; } if (autoCloudLoad) { SetUpAutoCloudLoad(); } IsGuestUserDefault = false; Logger.d("Attempting to sign in to Google Play Game Services."); PlayGamesPlatform.Instance.Authenticate(success => { // Success is handled by OnAutenticated method if (!success) { Logger.w("Failed to sign in to Google Play Game Services."); bool hasNoInternet; try { hasNoInternet = InternetConnectionUtils.GetConnectionStatus() != InternetConnectionStatus.Connected; } catch (NotSupportedException) { hasNoInternet = Application.internetReachability == NetworkReachability.NotReachable; } if (hasNoInternet) { Logger.d("Failure seems to be due to lack of Internet. Will try to connect again next time."); } else { Logger.d("Must assume the failure is due to player opting out" + " of the sign-in process, setting guest user as default"); IsGuestUserDefault = true; } cloudOnceEvents.RaiseOnSignInFailed(); if (autoCloudLoad) { cloudOnceEvents.RaiseOnCloudLoadComplete(false); } } CloudOnceUtils.SafeInvoke(callback, success); }); }
/// <summary> /// Load the user profiles accociated with the given array of user IDs. /// </summary> /// <param name="userIDs">The users to retrieve profiles for.</param> /// <param name="callback">Callback to handle the user profiles.</param> public override void LoadUsers(string[] userIDs, Action <IUserProfile[]> callback) { if (!IsGpgsInitialized) { Debug.LogWarning("LoadUsers called, but Google Play Game Services has not been initialized. Ignoring call."); CloudOnceUtils.SafeInvoke(callback, new IUserProfile[0]); return; } PlayGamesPlatform.Instance.LoadUsers(userIDs, callback); }
private void OnRevealCompleted(CloudRequestResult <bool> response, Action <CloudRequestResult <bool> > callbackAction) { if (response.Result) { isAchievementHidden = false; CloudOnceUtils.SafeInvoke(callbackAction, new CloudRequestResult <bool>(true)); } else { CloudOnceUtils.SafeInvoke(callbackAction, new CloudRequestResult <bool>(false, response.Error)); } }
/// <summary> /// Simulates signing in. /// </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) { isSignedIn = true; CloudOnceUtils.SafeInvoke(callback, true); cloudOnceEvents.RaiseOnSignedInChanged(true); var delay = Random.Range(0.5f, 2f); Debug.Log(string.Format("Simulating random PlayerImageDownload delay of {0} seconds", delay)); StartCoroutine( CloudOnceUtils.InvokeUnscaledTime( cloudOnceEvents.RaiseOnPlayerImageDownloaded, Texture2D.whiteTexture, delay)); }
/// <summary> /// Shows the GameCircle sign in page. If GameCircle is not initialized, /// the <see cref="Initialize"/> method will be called. /// </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'> /// Due to differences in how the GameCircle platform handles sign in (there is no SignIn method, only Init), /// the callback will always be <c>true</c>. /// </param> public override void SignIn(bool autoCloudLoad = true, UnityAction <bool> callback = null) { if (AGSClient.IsServiceReady()) { AGSClient.ShowSignInPage(); } else { Initialize(CloudSaveEnabled, true, autoCloudLoad); } CloudOnceUtils.SafeInvoke(callback, true); }
private void OnUnlockCompleted(CloudRequestResult <bool> response, Action <CloudRequestResult <bool> > callbackAction) { if (response.Result) { IsUnlocked = true; isAchievementHidden = false; Progress = 100.0; CloudOnceUtils.SafeInvoke(callbackAction, new CloudRequestResult <bool>(true)); } else { CloudOnceUtils.SafeInvoke(callbackAction, new CloudRequestResult <bool>(false, response.Error)); } }
private void OnIncrementCompleted(CloudRequestResult <bool> response, double progress, Action <CloudRequestResult <bool> > callbackAction) { if (response.Result) { Progress = progress; #if UNITY_IOS isAchievementHidden = false; #endif CloudOnceUtils.SafeInvoke(callbackAction, new CloudRequestResult <bool>(true)); } else { CloudOnceUtils.SafeInvoke(callbackAction, new CloudRequestResult <bool>(false, response.Error)); } }
private void OnUpdateAchievementCompleted(CloudRequestResult <bool> response, Action <CloudRequestResult <bool> > callbackAction) { var result = response.Result ? new CloudRequestResult <bool>(true) : new CloudRequestResult <bool>(false, response.Error); CloudOnceUtils.SafeInvoke(callbackAction, result); }
/// <summary> /// Load the user profiles accociated with the given array of user IDs. /// </summary> /// <param name="userIDs">The users to retrieve profiles for.</param> /// <param name="callback">Callback to handle the user profiles.</param> public override void LoadUsers(string[] userIDs, Action <IUserProfile[]> callback) { Debug.LogWarning("LoadUsers functionality does not exist on the Amazon GameCircle platform."); CloudOnceUtils.SafeInvoke(callback, new IUserProfile[0]); }