Beispiel #1
0
    public void requestAchievementsSucceeded(string json)
    {
        Debug.Log("GameCircleManager - requestAchievementsSucceeded");

        AGSAchievementsClient.
        RequestAchievementsSucceeded(json);
    }
Beispiel #2
0
        /// <summary>
        /// Unlocks an achievement.
        /// </summary>
        /// <param name="id">Current platform's ID for the achievement.</param>
        /// <param name="onComplete">
        /// Callback that will be called to report the result of the operation: <c>true</c> on success, <c>false</c> otherwise.
        /// If <c>false</c>, an error message will be included in the callback.
        /// </param>
        /// <param name="internalID">Internal CloudOnce ID, if available.</param>
        public void Unlock(string id, Action <CloudRequestResult <bool> > onComplete, string internalID = "")
        {
            if (string.IsNullOrEmpty(id))
            {
                ReportError("Can't unlock achievement. Supplied ID is null or empty!", onComplete);
                return;
            }

            if (!AGSPlayerClient.IsSignedIn())
            {
                var authenticationError = string.IsNullOrEmpty(internalID)
                    ? string.Format("Can't unlock {0}. UnlockAchievement can only be called after authentication.", id)
                    : string.Format("Can't unlock {0} ({1}). Unlock can only be called after authentication.", internalID, id);
                ReportError(authenticationError, onComplete);
                return;
            }

            Action <AGSUpdateAchievementResponse> callback = null;

            callback = response =>
            {
                OnReportCompleted(response, onComplete, unlockAction, id, internalID);
                AGSAchievementsClient.UpdateAchievementCompleted -= callback;
            };

            AGSAchievementsClient.UpdateAchievementCompleted += callback;
            AGSAchievementsClient.UpdateAchievementProgress(id, 100f);
        }
Beispiel #3
0
 public void ShowAcheivementsUI()
 {
             #if AMAZON
     AGSAchievementsClient.ShowAchievementsOverlay();
             #else
     Social.ShowAchievementsUI();
             #endif
 }
 /// <summary>
 /// Reports the achievement progress.
 /// </summary>
 /// <param name='achievementID'>
 /// Achievement ID.
 /// </param>
 /// <param name='progress'>
 /// Progress.
 /// </param>
 /// <param name='callback'>
 /// Callback.
 /// </param>
 public void ReportProgress(string achievementID, double progress, System.Action <bool> callback)
 {
     // Forward the AGSClient callbacks to the passed in callback.
     if (null != callback)
     {
         AGSAchievementsClient.UpdateAchievementSucceededEvent += (a) => { callback(true); };
         AGSAchievementsClient.UpdateAchievementFailedEvent    += (a, e) => { callback(false); };
     }
     AGSAchievementsClient.UpdateAchievementProgress(achievementID, (float)progress);
 }
 /// <summary>
 /// Reports progress made for this achievement.
 /// </summary>
 /// <param name='callback'>
 /// Callback.
 /// </param>
 public void ReportProgress(System.Action <bool> callback)
 {
     // Forward the AGSClient callbacks to the passed in callback.
     if (null != callback)
     {
         AGSAchievementsClient.UpdateAchievementSucceededEvent += (a) => { callback(true); };
         AGSAchievementsClient.UpdateAchievementFailedEvent    += (a, e) => { callback(false); };
     }
     AGSAchievementsClient.UpdateAchievementProgress(id, (float)percentCompleted);
 }
Beispiel #6
0
 /// <summary>
 /// Loads the achievements.
 /// </summary>
 /// <param name='callback'>
 /// Callback.
 /// </param>
 public void LoadAchievements(System.Action <IAchievement[]> callback)
 {
     // The callback argument should not be null for this function.
     if (null == callback)
     {
         AGSClient.LogGameCircleError("LoadAchievements \"callback\" argument should not be null");
         return;
     }
     loadAchievementsCallbacks.Add(requestID, callback);
     AGSAchievementsClient.RequestAchievements(requestID++);
 }
Beispiel #7
0
 public void ShowAchievementsPage()
 {
     if (AGSClient.IsServiceReady())
     {
         AGSAchievementsClient.ShowAchievementsOverlay();
     }
     else
     {
         Debug.Log("Show sigin page Service NOOOOOOT Ready");
     }
 }
Beispiel #8
0
 /// <summary>
 /// Requests the list of Achievements from the GameCircle plugin.
 /// </summary>
 void RequestAchievements()
 {
     // start the clock, to track the progress of this async operation
     achievementsRequestTime = System.DateTime.Now;
     // subscribe to the events to receive the achievement list.
     SubscribeToAchievementRequestEvents();
     // request the achievement list from the GameCircle plugin.
     AGSAchievementsClient.RequestAchievements();
     // set the request status message to show that achievement retrieval has begun.
     requestAchievementsStatus = requestingAchievementsLabel;
 }
Beispiel #9
0
    public void RequestAchievements()
    {
        if (AGSPlayerClient.IsSignedIn() == false)
        {
            return;
        }

        // subscribe to the events to receive the achievement list.
        SubscribeToAchievementRequestEvents();
        // request the achievement list from the GameCircle plugin.
        AGSAchievementsClient.RequestAchievements();
    }
Beispiel #10
0
        IEnumerator FindReportAchievement(string iOSID)
        {
            yield return(StartCoroutine(CoreMethods.Wait(0f)));

            Achievement ad = null;

            foreach (Achievement ad1 in GameUtility.Me.achievements)
            {
                if (ad1.keyGameCenteriOS.Equals(iOSID))
                {
                    ad = ad1;
                }
            }
            if (ad == null)
            {
                MyDebug.Log("AchievementManager::FindReportAchievement => Achievement: " + iOSID + " not available");
                yield break;
            }
            if (ad.isAchieved)
            {
                MyDebug.Log("AchievementManager::FindReportAchievement => Achievement " + iOSID + " all ready reported");
                yield break;
            }
            //Reporting to data to GameCentre / Google Play service / Swarm / Amazon
#if UNITY_IOS
            if (!string.IsNullOrEmpty(ad.keyGameCenteriOS))
            {
                ReportAchievement(ad.keyGameCenteriOS);
            }
#endif

#if UNITY_ANDROID
#if GPGSERVIES && !AMAZONSTORE
            if (!string.IsNullOrEmpty(ad.keyGooglePlayService))
            {
                ReportAchievement(ad.keyGooglePlayService);
            }
#endif
#if AMAZONSTORE && GAMECIRCLE
            if (!string.IsNullOrEmpty(ad.AmazonID))
            {
                AGSAchievementsClient.UpdateAchievementProgress(ad.AmazonID, 100f);
            }
#endif
#endif
            ad.isAchieved = true;
            //TODO: Report Achievement Unlocked to analytics System

            //TODO: Save Your Player Progress now.
            //PlayerPrefs.SetInt(ad.PrefKey, 1);
        }
Beispiel #11
0
 /// <summary>
 /// Submits an achievement progress update to the GameCircle plugin.
 /// </summary>
 /// <param name='achievementId'>
 /// Achievement identifier.
 /// </param>
 /// <param name='progress'>
 /// Progress. At 100, achievement is unlocked.
 /// </param>
 void SubmitAchievement(string achievementId, float progress)
 {
     // Subscribe to the events to receive the achievement submission status message
     SubscribeToSubmitAchievementEvents();
     // Submit the achievement update to the GameCircle plugin.
     AGSAchievementsClient.UpdateAchievementProgress(achievementId, progress);
     // Make sure the submission status dictionary has a key for this achievement ID.
     if (!achievementsSubmissionStatus.ContainsKey(achievementId))
     {
         achievementsSubmissionStatus.Add(achievementId, null);
     }
     // Update the status of this achievement to show submission has begun.
     achievementsSubmissionStatus[achievementId] = string.Format(submittingInformationString);
 }
Beispiel #12
0
        /// <summary>
        /// Shows the native achievement user interface, allowing the player to browse achievements.
        /// </summary>
        public void ShowOverlay()
        {
            if (!AGSPlayerClient.IsSignedIn())
            {
#if CLOUDONCE_DEBUG
                UnityEngine.Debug.LogWarning("ShowOverlay can only be called after authentication.");
#endif
                return;
            }
#if CLOUDONCE_DEBUG
            UnityEngine.Debug.Log("Showing achievements overlay.");
#endif
            AGSAchievementsClient.ShowAchievementsOverlay();
        }
Beispiel #13
0
        private static void UpdateAchievementsData()
        {
            AGSAchievementsClient.RequestAchievementsCompleted -= OnRequestAchievementsCompleted;
            AGSAchievementsClient.RequestAchievementsCompleted += OnRequestAchievementsCompleted;

            if (!AGSPlayerClient.IsSignedIn())
            {
#if CO_DEBUG
                Debug.LogWarning("AGSAchievementsClient.RequestAchievements(); can only be called after authentication.");
#endif
                return;
            }

            AGSAchievementsClient.RequestAchievements();
        }
    /// <summary>
    /// Loads the achievement descriptions.
    /// </summary>
    /// <param name='callback'>
    /// Callback.
    /// </param>
    public void LoadAchievementDescriptions(System.Action <IAchievementDescription[]> callback)
    {
        // The callback argument should not be null for this function.
        if (null == callback)
        {
            AGSClient.LogGameCircleError("LoadAchievementDescriptions \"callback\" argument should not be null");
            return;
        }

        // Transform the passed in callback action to the type of callback the GameCircle plugin expects.
        AGSAchievementsClient.RequestAchievementsFailedEvent    += (e) => { callback(null); };
        AGSAchievementsClient.RequestAchievementsSucceededEvent += (achievements) => {
            AGSSocialAchievementDescription [] descriptions = new AGSSocialAchievementDescription[achievements.Count];
            for (int achievementIndex = 0; achievementIndex < achievements.Count; achievementIndex++)
            {
                descriptions[achievementIndex] = new AGSSocialAchievementDescription(achievements[achievementIndex]);
            }
            callback(descriptions);
        };
        AGSAchievementsClient.RequestAchievements();
    }
Beispiel #15
0
 public void PostAchievement(string ID)
 {
             #if AMAZON
     {
         AGSAchievementsClient.UpdateAchievementSucceededEvent += Instance.updateAchievementSucceeded;
         AGSAchievementsClient.UpdateAchievementFailedEvent    += Instance.updateAchievementFailed;
         AGSAchievementsClient.UpdateAchievementProgress(ID, 100.0f);
     }
             #else
     Social.ReportProgress(ID, 100.0f, (bool success) => {
         // handle success or failure
         if (success)
         {
             //				Debug.Log("PostAchievement = " + ID);
         }
         else
         {
             //				Debug.Log ("PostAchievement Fail");
         }
     });
             #endif
 }
Beispiel #16
0
 public void RequestAchievements()
 {
             #if AMAZON_CIRCLE_ENABLED
     AGSAchievementsClient.RequestAchievements();
             #endif
 }
 public void requestAchievementsFailed(string json)
 {
     AGSClient.Log("AGSAchievementsClient - RequestAchievementsFailed");
     AGSAchievementsClient.RequestAchievementsFailed(json);
 }
 public void requestAchievementsForPlayerCompleted(string json)
 {
     AGSClient.Log("AGSAchievementsClient - RequestAchievementsForPlayerComplete");
     AGSAchievementsClient.RequestAchievementsForPlayerComplete(json);
 }
Beispiel #19
0
 public void updateAchievementFailed(string json)
 {
     AGSClient.Log("GameCircleManager - updateAchievementsFailed");
     AGSAchievementsClient.
     UpdateAchievementFailed(json);
 }
 public void updateAchievementFailed(string json)
 {
     AGSClient.Log("AGSAchievementsClient - UpdateAchievementFailed");
     AGSAchievementsClient.UpdateAchievementFailed(json);
 }
Beispiel #21
0
 //submit progress
 public void UpdateAchievementProgress(string achieve_id, float score)
 {
             #if AMAZON_CIRCLE_ENABLED
     AGSAchievementsClient.UpdateAchievementProgress(achieve_id, score);
             #endif
 }
Beispiel #22
0
 public void updateAchievementSucceeded(string json)
 {
     Debug.Log("GameCircleManager - updateAchievementSucceeded");
     AGSAchievementsClient.UpdateAchievementSucceeded(json);
 }
Beispiel #23
0
    /// <summary>
    /// Draws the Achievements menu. Note that this must be called from an OnGUI function.
    /// </summary>
    public override void DrawMenu()
    {
        // This button will open the achievements overlay.
        if (GUILayout.Button(displayAchievementOverlayButtonLabel))
        {
            AGSAchievementsClient.ShowAchievementsOverlay();
        }

        // If achievement information retrieval has not begun,
        // display a button to begin the functionality.
        if (string.IsNullOrEmpty(requestAchievementsStatus))
        {
            // This button will begin retrieval of achievement information.
            if (GUILayout.Button(requestAchievementsButtonLabel))
            {
                RequestAchievements();
            }
        }
        else
        {
            // once a request has been made for the list of achievements,
            // display the status message of that process.
            AmazonGUIHelpers.CenteredLabel(requestAchievementsStatus);
            if (!string.IsNullOrEmpty(requestAchievementsStatusMessage))
            {
                AmazonGUIHelpers.CenteredLabel(requestAchievementsStatusMessage);
            }

            // If the achievements are not ready, display how long it has been since the request was put in
            // to make it clear this is an asynchronous operation.
            if (!achievementsReady)
            {
                AmazonGUIHelpers.CenteredLabel(string.Format(achievementRequestTimeLabel, (System.DateTime.Now - achievementsRequestTime).TotalSeconds));
            }
            // once achievement retrieval is successful, display the list of achievements.
            else
            {
                // If the achievement list was not empty, display it.
                if (null != achievementList && achievementList.Count > 0)
                {
                    foreach (AGSAchievement achievement in achievementList)
                    {
                        DisplayAchievement(achievement);
                    }
                }
                else
                {
                    // You will only see this message if there is no list of achievements.
                    // This happens in two cases:
                    //      You have not added any achievements to your project on the GameCircle website.
                    //      You only have draft achievements, and the user you are testing with cannot see draft achievements.
                    AmazonGUIHelpers.CenteredLabel(noAchievementsAvailableLabel);
                }
                // display an "invalid" achievement to ensure that GameCircle handles invalid data properly.
                if (null != invalidAchievement)
                {
                    DisplayAchievement(invalidAchievement);
                }
            }
        }
    }
Beispiel #24
0
 public void SubmitAchievement(string achievementId, float progress)
 {
     // Submit the achievement update to the GameCircle plugin.
     AGSAchievementsClient.UpdateAchievementProgress(achievementId, progress);
 }
Beispiel #25
0
 /// <summary>
 /// Load the achievements the logged in user has already achieved or reported progress on.
 /// </summary>
 /// <param name="callback">Callback to handle the achievements.</param>
 public void LoadAchievements(Action <IAchievement[]> callback)
 {
     loadAchievementsCallbacks.Add(AmazonLeaderboardUtils.RequestID, callback);
     AGSAchievementsClient.RequestAchievements(AmazonLeaderboardUtils.RequestID++);
 }
Beispiel #26
0
 /// <summary>
 /// Shows the achievements UI.
 /// </summary>
 public void ShowAchievementsUI()
 {
     AGSAchievementsClient.ShowAchievementsOverlay();
 }
Beispiel #27
0
 public void ShowAchievementsOverlay()
 {
             #if AMAZON_CIRCLE_ENABLED
     AGSAchievementsClient.ShowAchievementsOverlay();
             #endif
 }
Beispiel #28
0
 /// <summary>
 /// Reports the achievement progress.
 /// </summary>
 /// <param name='achievementID'>
 /// Achievement ID.
 /// </param>
 /// <param name='progress'>
 /// Progress.
 /// </param>
 /// <param name='callback'>
 /// Callback.
 /// </param>
 public void ReportProgress(string achievementID, double progress, System.Action <bool> callback)
 {
     simpleCallbacks.Add(requestID, callback);
     AGSAchievementsClient.UpdateAchievementProgress(achievementID, (float)progress, requestID++);
 }
Beispiel #29
0
 public void requestAchievementsFailed(string json)
 {
     AGSClient.Log("GameCircleManager -  requestAchievementsFailed");
     AGSAchievementsClient.
     RequestAchievementsFailed(json);
 }