/// <summary>
        /// Loads any available cloud data (if signed in and cloud saving is enabled).
        /// </summary>
        public void Load()
        {
            if (!AmazonCloudProvider.Instance.CloudSaveInitialized || !Cloud.CloudSaveEnabled)
            {
#if CO_DEBUG
                Debug.LogWarning(!AmazonCloudProvider.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 (AGSClient.IsServiceReady())
            {
#if CO_DEBUG
                Debug.Log("Loading cloud data");
#endif
                AGSWhispersyncClient.Synchronize();
                cloudOnceEvents.RaiseOnCloudLoadComplete(true);
            }
            else
            {
                Debug.LogWarning("Attempted to load cloud data, but the AGS service is not ready.");
                cloudOnceEvents.RaiseOnCloudLoadComplete(false);
            }
        }
Beispiel #2
0
 public void OnAppplicationQuit()
 {
     AGSClient.Log("GameCircleManager - OnApplicationQuit");
     if (AGSClient.IsServiceReady())
     {
         AGSClient.Shutdown();
     }
 }
        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
            }
        }
Beispiel #4
0
    /// <summary>
    /// Unity / MonoBehaviour function for GUI behaviour.
    /// </summary>
    void OnGUI()
    {
        // Some initialization behaviour can only be called from within the OnGUI function.
        // initialize UI early returns if it is already initialized
        InitializeUI();

        // This menu has a local UI skin with buttons scaled up, and other touch enhancements.
        ApplyLocalUISkin();

        AmazonGUIHelpers.BeginMenuLayout();

        // Wrapping all of the menu in a scroll view allows the individual menu systems to not need to handle being off screen.
        scroll = GUILayout.BeginScrollView(scroll);

        // Display if the GameCircle plugin is ready..
        AmazonGUIHelpers.CenteredLabel(string.Format(isServiceReadyLabel, AGSClient.IsServiceReady()));

        // If GameCircle is not initialized, display the initialization menu.
        if (initializationMenu.InitializationStatus != AmazonGameCircleExampleInitialization.EInitializationStatus.Ready)
        {
            initializationMenu.DrawMenu();
        }
        else
        {
            // This button opens the generic GameCircle overlay.
            if (GUILayout.Button(gameCircleOverlayButtonLabel))
            {
                AGSClient.ShowGameCircleOverlay();
            }

            // This button opens the GameCircle sign in page.
            if (GUILayout.Button(gameCircleSignInButtonLabel))
            {
                AGSClient.ShowSignInPage();
            }

            // Once GameCircle is initialized, display all submenus, for achievements, leaderboards, and other GameCircle features.
            foreach (AmazonGameCircleExampleBase subMenu in gameCircleExampleMenus)
            {
                GUILayout.BeginVertical(GUI.skin.box);
                subMenu.foldoutOpen = AmazonGUIHelpers.FoldoutWithLabel(subMenu.foldoutOpen, subMenu.MenuTitle());
                if (subMenu.foldoutOpen)
                {
                    subMenu.DrawMenu();
                }
                GUILayout.EndVertical();
            }
        }

        GUILayout.EndScrollView();

        AmazonGUIHelpers.EndMenuLayout();

        // If the UI skin is not reverted at the end of the function,
        // any other OnGUI behavior might end up using the settings applied here.
        RevertLocalUISkin();
    }
 private void Start()
 {
     if (AGSClient.IsServiceReady() && AGSPlayerClient.IsSignedIn())
     {
         if (Managers.GameCircleAmazon.achievementList == null)
         {
             Managers.GameCircleAmazon.RequestAchievements();
         }
     }
 }
        /// <summary>
        /// Shuts down the GameCircle service.
        /// </summary>
        public override void SignOut()
        {
            if (!AGSClient.IsServiceReady())
            {
                // Not signed in, ignoring call.
                return;
            }

            AGSClient.Shutdown();
        }
Beispiel #7
0
 public void ShowAchievementsPage()
 {
     if (AGSClient.IsServiceReady())
     {
         AGSAchievementsClient.ShowAchievementsOverlay();
     }
     else
     {
         Debug.Log("Show sigin page Service NOOOOOOT Ready");
     }
 }
Beispiel #8
0
 public void ShowGameCircle()
 {
     if (AGSClient.IsServiceReady())
     {
         AGSClient.ShowGameCircleOverlay();
     }
     else
     {
         Debug.Log("Show sigin page Service NOOOOOOT Ready");
     }
 }
Beispiel #9
0
 public void ShowLeaderBoardPage()
 {
     if (AGSClient.IsServiceReady())
     {
         AGSLeaderboardsClient.ShowLeaderboardsOverlay();
     }
     else
     {
         Debug.Log("Show sigin page Service NOOOOOOT Ready");
     }
 }
 /// <summary>
 /// Shows the Amazon GameCircle overlay.
 /// </summary>
 public void ShowNativeOverlay()
 {
     if (AGSClient.IsServiceReady())
     {
         AGSClient.ShowGameCircleOverlay();
     }
     else
     {
         Debug.LogWarning("Can't show native overlay. Service is not ready. Call Initialize first.");
     }
 }
Beispiel #11
0
 void Update()
 {
     if (WhisperInitialized == false)
     {
         if (AGSClient.IsServiceReady())
         {
             Debug.Log("UPdate de amazon");
             WhisperInitialized = true;
             WhisperPlayerScores.Instance.Initialize();
         }
     }
 }
Beispiel #12
0
 public void ShowSignInPage()
 {
     if (AGSClient.IsServiceReady())
     {
         Debug.Log("Show sigin page Service Ready");
         AGSClient.ShowSignInPage();
     }
     else
     {
         Debug.Log("Show sigin page Service NOOOOOOT Ready");
     }
 }
Beispiel #13
0
    public void OnApplicationFocus(Boolean focusStatus)
    {
        if (!AGSClient.IsServiceReady())
        {
            return;
        }

        if (!focusStatus)
        {
            AGSClient.release();
        }
    }
        /// <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);
        }
Beispiel #15
0
    void InitializeGameCircle()
    {
        //Revisar si service readu
        if (AGSClient.IsServiceReady())
        {
            return;
        }
        // Step the initialization progress forward.
        initializationStatus = EInitializationStatus.InitializationRequested;


        SubscribeToGameCircleInitializationEvents();
        //  SubscribeToSubmitAchievementEvents();

        // Begin GameCircle initialization.
        Debug.Log("Llamando a Init GameCircle");
        AGSClient.Init(usesLeaderboards, usesAchievements, usesWhispersync);
    }
Beispiel #16
0
        /// <summary>
        /// Clears all cloud variables currently stored in the cloud.
        /// </summary>
        private static void DeleteCloudData()
        {
#if !UNITY_EDITOR && UNITY_ANDROID
#if CLOUDONCE_AMAZON
            if (AGSClient.IsServiceReady())
            {
                using (var dataMap = AGSWhispersyncClient.GetGameData())
                {
                    using (var developerString = dataMap.getDeveloperString(DevStringKey))
                    {
                        developerString.setValue(string.Empty);
                        if (AGSPlayerClient.IsSignedIn())
                        {
                            AGSWhispersyncClient.Synchronize();
                        }
                        else
                        {
                            AGSWhispersyncClient.Flush();
                        }
                    }
                }
            }
#elif CLOUDONCE_GOOGLE
            if (GooglePlayGamesCloudProvider.Instance.IsGpgsInitialized && PlayGamesPlatform.Instance.IsAuthenticated())
            {
                PlayGamesPlatform.Instance.SavedGame.OpenWithAutomaticConflictResolution(
                    "GameData",
                    DataSource.ReadCacheOrNetwork,
                    ConflictResolutionStrategy.UseLongestPlaytime,
                    (status, metadata) =>
                {
                    if (status == SavedGameRequestStatus.Success)
                    {
                        PlayGamesPlatform.Instance.SavedGame.Delete(metadata);
                    }
                });
            }
#endif
#elif !UNITY_EDITOR && UNITY_IOS
            iCloudBridge.DeleteString(DevStringKey);
#endif
            PlayerPrefs.DeleteKey(DevStringKey);
            PlayerPrefs.Save();
        }
        /// <summary>
        /// Check if the game service is initialized
        /// </summary>
        public static bool IsInitialized()
        {
                        #if UNITY_EDITOR
            return(false);
                        #else
                        #if UNITY_IOS
            return(Social.localUser.authenticated);
                        #endif

                        #if UNITY_AMAZON
            bool isServiceReady = AGSClient.IsServiceReady();
            return(isServiceReady);
                        #endif

                        #if UNITY_ANDROID
            return(Social.localUser.authenticated);
                        #endif

            return(false);
                        #endif
        }
    // Use this for initialization

    void Start()
    {
        return;

                #if UNITY_ANDROID
        if (UserPrefs.isAmazonBuild)
        {
            bool isServiceReady = AGSClient.IsServiceReady();

            if (!isServiceReady)
            {
                AGSClient.ServiceReadyEvent    += serviceReadyHandler;
                AGSClient.ServiceNotReadyEvent += serviceNotReadyHandler;

                AGSClient.Init(true, true, false);                 //usesLeaderboards, usesAchievements, usesWhispersync
            }
        }
                #endif
#if UNITY_IPHONE
        GameCenterBinding.authenticateLocalPlayer();
#endif
    }
Beispiel #19
0
 public void PostScoreToLeaderBoard()
 {
             #if AMAZON
     if (AGSClient.IsServiceReady())
     {
         AGSLeaderboardsClient.SubmitScoreSucceededEvent += Instance.submitScoreSucceeded;
         AGSLeaderboardsClient.SubmitScoreFailedEvent    += Instance.submitScoreFailed;
         AGSLeaderboardsClient.SubmitScore(Constants.LEADER_BOARD_ID, Instance.puzzleSolved);
     }
             #else
     if (Social.localUser.authenticated)
     {
                     #if UNITY_ANDROID
         Social.ReportScore(Instance.puzzleSolved, Constants.LEADER_BOARD_ID, (bool success) =>
         {
             if (success)
             {
             }
             else
             {
                 //					Debug.Log ("Add Score Fail");
             }
         });
                     #elif UNITY_IOS
         Social.ReportScore(Instance.puzzleSolved, Constants.LEADER_BOARD_ID, (bool success) =>
         {
             if (success)
             {
             }
             else
             {
                 //					Debug.Log ("Add Score Fail");
             }
         });
                     #endif
     }
             #endif
 }
Beispiel #20
0
 public void UpdateAchievements()
 {
     if (AGSClient.IsServiceReady() && AGSPlayerClient.IsSignedIn())
     {
         if (achievementList != null)
         {
             foreach (AGSAchievement agsAchievement in achievementList)
             {
                 if (agsAchievement.isUnlocked == false)
                 {
                     Debug.Log("Achievement no esta lock" + agsAchievement.id);
                     float progress = Managers.Achievements.AchievementProgress(agsAchievement.id);
                     if (progress > 0)
                     {
                         SubmitAchievement(agsAchievement.id, progress);
                     }
                 }
             }
         }
         else // La lista de achievements no se cargo, tratar de cargarla entonces
         {
         }
     }
 }
        /// <summary>
        /// Saves all cloud variables, to both disk and cloud.
        /// If <see cref="Cloud.CloudSaveEnabled"/> is <c>false</c>, it will only save to disk.
        /// Skips saving if no variables have been changed.
        /// </summary>
        public void Save()
        {
            if (saveInitialized)
            {
                return;
            }

            saveInitialized = true;

            DataManager.SaveToDisk();
            if (!AmazonCloudProvider.Instance.CloudSaveInitialized || !Cloud.CloudSaveEnabled)
            {
#if CO_DEBUG
                Debug.LogWarning(!AmazonCloudProvider.Instance.CloudSaveInitialized
                    ? "Cloud Save has not been initialized, skipping upload and only saving to disk."
                    : "Cloud Save is currently disabled, skipping upload and only saving to disk.");
#endif
                saveInitialized = false;
                cloudOnceEvents.RaiseOnCloudSaveComplete(false);
                return;
            }

            if (DataManager.IsLocalDataDirty)
            {
                if (AGSClient.IsServiceReady())
                {
#if CO_DEBUG
                    Debug.Log("Saving cloud data");
#endif
                    using (var dataMap = AGSWhispersyncClient.GetGameData())
                    {
                        using (var developerString = dataMap.getDeveloperString(DataManager.DevStringKey))
                        {
                            developerString.setValue(DataManager.SerializeLocalData().ToBase64String());
                            if (AGSPlayerClient.IsSignedIn())
                            {
                                AGSWhispersyncClient.Synchronize();
                            }
                            else
                            {
                                AGSWhispersyncClient.Flush();
                            }

                            saveInitialized = false;
                            DataManager.IsLocalDataDirty = false;
                            cloudOnceEvents.RaiseOnCloudSaveComplete(true);
                        }
                    }
                }
                else
                {
                    saveInitialized = false;
                    Debug.LogWarning("Attempted to save cloud data, but the AGS service is not ready.");
                    cloudOnceEvents.RaiseOnCloudSaveComplete(false);
                }
            }
            else
            {
#if CO_DEBUG
                Debug.Log("Save called, but no data has changed since last save.");
#endif
                saveInitialized = false;
                cloudOnceEvents.RaiseOnCloudSaveComplete(false);
            }
        }