private static void ReportSubmitScoreSuccess(long score, Action <CloudRequestResult <bool> > callbackAction, string id, string internalID)
        {
#if CLOUDONCE_DEBUG
            Debug.Log(string.Format("Successfully submitted a score of {0} to {1} ({2}) leaderboard.", score, internalID, id));
#endif
            CloudOnceUtils.SafeInvoke(callbackAction, new CloudRequestResult <bool>(true));
        }
        private static void OnSubmitScoreCompleted(
            AGSRequestResponse response,
            long score,
            Action <CloudRequestResult <bool> > callbackAction,
            string id,
            string internalID)
        {
            if (!response.IsError())
            {
#if CLOUDONCE_DEBUG
                var debugMessage = string.Format(
                    "Successfully submitted a score of {0} to {1} ({2}) leaderboard.",
                    score,
                    internalID,
                    id);
                UnityEngine.Debug.Log(debugMessage);
#endif
                CloudOnceUtils.SafeInvoke(callbackAction, new CloudRequestResult <bool>(true));
            }
            else
            {
                var errorMessage = string.Format(
                    "Native API failed to submit a score of {0} to {1} ({2}) leaderboard.\nReported error: {3}",
                    score,
                    internalID,
                    id,
                    response.error);
                ReportError(errorMessage, callbackAction);
            }
        }
        private static void ReportError(string errorMessage, Action <CloudRequestResult <bool> > callbackAction)
        {
#if CLOUDONCE_DEBUG
            Debug.LogWarning(errorMessage);
#endif
            CloudOnceUtils.SafeInvoke(callbackAction, new CloudRequestResult <bool>(false, errorMessage));
        }
Esempio n. 4
0
        /// <summary>
        /// Reports a score to a leaderboard.
        /// </summary>
        /// <param name="id">Current platform's ID for the leaderboard.</param>
        /// <param name="score">The score to submit.</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 SubmitScore(string id, long score, Action <CloudRequestResult <bool> > onComplete, string internalID = "")
        {
            if (string.IsNullOrEmpty(id))
            {
                ReportError(string.Format("Can't submit score to {0} leaderboard. Platform ID is null or empty!", internalID), onComplete);
                return;
            }

#if CLOUDONCE_DEBUG
            Debug.Log(string.Format("Successfully submitted a score of {0} to {1} ({2}) leaderboard.", score, internalID, id));
#endif
            CloudOnceUtils.SafeInvoke(onComplete, new CloudRequestResult <bool>(true));
        }
Esempio n. 5
0
        private static void OnSubmitScoreCompleted(bool response, long score, Action <CloudRequestResult <bool> > callbackAction, string id, string internalID)
        {
            if (response)
            {
#if CLOUDONCE_DEBUG
                Debug.Log(string.Format("Successfully submitted a score of {0} to {1} ({2}) leaderboard.", score, internalID, id));
#endif
                CloudOnceUtils.SafeInvoke(callbackAction, new CloudRequestResult <bool>(true));
            }
            else
            {
                var error = string.Format("Native API failed to submit a score of {0} to {1} ({2}) leaderboard. Cause unknown.", score, internalID, id);
                ReportError(error, callbackAction);
            }
        }
        private static void OnReportCompleted(bool response, Action <CloudRequestResult <bool> > callbackAction, string action, string id, string internalID)
        {
            if (response)
            {
#if CLOUDONCE_DEBUG
                Debug.Log(string.Format("Achievement {0} ({1}) was successfully {2}ed.", internalID, id, action));
#endif
                CloudOnceUtils.SafeInvoke(callbackAction, new CloudRequestResult <bool>(true));
            }
            else
            {
                // Customize error message to fit either new or old achievement system.
                var error = string.IsNullOrEmpty(internalID)
                        ? string.Format("Native API failed to {0} achievement {1}. Cause unknown.", action, id)
                        : string.Format("Native API failed to {0} achievement {1} ({2}). Cause unknown.", action, internalID, id);
                ReportError(error, callbackAction);
            }
        }
 /// <summary>
 /// Load a default set of scores from the given leaderboard.
 /// </summary>
 /// <param name="leaderboardID">Current platform's ID for the leaderboard.</param>
 /// <param name="callback">Callback with scores.</param>
 public void LoadScores(string leaderboardID, Action <IScore[]> callback)
 {
     Debug.LogWarning("Leaderboards overlay is not supported in the Unity Editor.");
     CloudOnceUtils.SafeInvoke(callback, new IScore[0]);
 }
 private static void IncrementAchievementCallback(bool success)
 {
     CloudOnceUtils.SafeInvoke(s_onAppleIncrementCompleted, success);
 }
 /// <summary>
 /// Send notification about progress on this achievement.
 /// </summary>
 /// <param name="callback">Callback indicating whether report is successful or not.</param>
 public void ReportProgress(Action <bool> callback)
 {
     CloudOnceUtils.SafeInvoke(callback, true);
 }
 /// <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)
 {
     CloudOnceUtils.SafeInvoke(callback, GetTestAchievements());
 }