예제 #1
0
        private void LoadImpl(string devString)
        {
#if CO_DEBUG
            Debug.Log("Loading cloud data");
#endif
            var changedKeys = DataManager.MergeLocalDataWith(devString);
            if (changedKeys.Length > 0)
            {
                cloudOnceEvents.RaiseOnNewCloudValues(changedKeys);
            }

            cloudOnceEvents.RaiseOnCloudLoadComplete(true);
        }
예제 #2
0
        private void OnDataStringLoaded(string dataString)
        {
            var allKeys = DataManager.ReplaceLocalDataWith(dataString);

            cloudOnceEvents.RaiseOnNewCloudValues(allKeys);
            cloudOnceEvents.RaiseOnCloudLoadComplete(true);
        }
        private void ProcessCloudData()
        {
            if (processingCloudData)
            {
                return;
            }

            processingCloudData = true;

            if (AGSClient.IsServiceReady())
            {
                using (var dataMap = AGSWhispersyncClient.GetGameData())
                {
                    using (var developerString = dataMap.getDeveloperString(DataManager.DevStringKey))
                    {
                        var cloudValue = developerString.getCloudValue();
                        if (string.IsNullOrEmpty(cloudValue))
                        {
#if CO_DEBUG
                            Debug.Log("No data saved to the cloud yet.");
#endif
                            processingCloudData = false;
                            return;
                        }

                        if (!cloudValue.IsJson())
                        {
                            try
                            {
                                cloudValue = cloudValue.FromBase64StringToString();
                            }
                            catch (FormatException)
                            {
                                Debug.LogWarning("Unable to deserialize cloud data!");
                                return;
                            }
                        }
#if CO_DEBUG
                        Debug.Log("Processing cloud data");
#endif
                        var changedKeys = DataManager.MergeLocalDataWith(cloudValue);
                        if (changedKeys.Length > 0)
                        {
                            cloudOnceEvents.RaiseOnNewCloudValues(changedKeys);
                        }

                        processingCloudData = false;
                    }
                }
            }
            else
            {
                processingCloudData = false;
#if CO_DEBUG
                Debug.LogWarning("Attempting to process cloud data, but the AGS service is not ready!");
#endif
            }
        }
        private void ProcessCloudData(byte[] cloudData)
        {
            if (cloudData == null)
            {
#if CLOUDONCE_DEBUG
                Debug.Log("No data saved to the cloud yet.");
#endif
                s_loadInitialized = false;
                cloudOnceEvents.RaiseOnCloudLoadComplete(true);
                return;
            }

            var dataString = BytesToString(cloudData);
            if (!string.IsNullOrEmpty(dataString))
            {
                if (!dataString.IsJson())
                {
                    try
                    {
                        dataString = dataString.FromBase64StringToString();
                    }
                    catch (FormatException)
                    {
                        Debug.LogWarning("Unable to deserialize cloud data!");
                        cloudOnceEvents.RaiseOnCloudLoadComplete(false);
                        return;
                    }
                }

                var changedKeys = DataManager.MergeLocalDataWith(dataString);
                if (changedKeys.Length > 0)
                {
                    cloudOnceEvents.RaiseOnNewCloudValues(changedKeys);
                }

                s_loadInitialized = false;
                cloudOnceEvents.RaiseOnCloudLoadComplete(true);
            }
            else
            {
#if CLOUDONCE_DEBUG
                Debug.Log("No data saved to the cloud yet.");
#endif
                s_loadInitialized = false;
                cloudOnceEvents.RaiseOnCloudLoadComplete(true);
            }
        }
예제 #5
0
        /// <summary>
        /// Loads any available cloud data (if signed in and cloud saving is enabled).
        /// </summary>
        public void Load()
        {
            if (!TestProvider.Instance.CloudSaveInitialized || !Cloud.CloudSaveEnabled)
            {
#if CO_DEBUG
                Debug.LogWarning(!TestProvider.Instance.CloudSaveInitialized
                    ? "Cloud Save has not been initialized, aborting cloud load."
                    : "Cloud Save is currently disabled, aborting cloud load.");
#endif
                cloudOnceEvents.RaiseOnCloudLoadComplete(false);
                return;
            }

            if (Cloud.IsSignedIn)
            {
#if CO_DEBUG
                Debug.Log("Simulating cloud load.");
#endif
                var changedKeys = DataManager.GetRandomKeysFromGameData();
                if (changedKeys.Length > 0)
                {
#if CO_DEBUG
                    Debug.Log("Simulating new cloud values (randomized).");
#endif
                    cloudOnceEvents.RaiseOnNewCloudValues(changedKeys);
                }

                cloudOnceEvents.RaiseOnCloudLoadComplete(true);
            }
            else
            {
                Debug.LogWarning("Attempted to load cloud data, but the local user is not signed in." +
                                 " Will try to re-initialize.");
                Cloud.Initialize();
                cloudOnceEvents.RaiseOnCloudLoadComplete(false);
            }
        }
예제 #6
0
        private void ProcessCloudData(byte[] cloudData)
        {
            if (cloudData == null)
            {
#if CLOUDONCE_DEBUG
                Debug.Log("No data saved to the cloud yet.");
#endif
                s_loadInitialized = false;
                cloudOnceEvents.RaiseOnCloudLoadComplete(true);
                return;
            }

            var dataString = GetDataString(cloudData);
            if (!string.IsNullOrEmpty(dataString))
            {
                var changedKeys = DataManager.MergeLocalDataWith(dataString);
                if (changedKeys.Length > 0)
                {
                    cloudOnceEvents.RaiseOnNewCloudValues(changedKeys);
                }

                s_loadInitialized = false;
                cloudOnceEvents.RaiseOnCloudLoadComplete(true);
            }
            else
            {
#if CLOUDONCE_DEBUG
                if (dataString != null)
                {
                    Debug.Log("No data saved to the cloud yet.");
                }
#endif
                s_loadInitialized = false;
                cloudOnceEvents.RaiseOnCloudLoadComplete(true);
            }
        }