public static AGSUpdateAchievementResponse GetBlankResponseWithError(string error, string achievementId = "", int userData = 0) { AGSUpdateAchievementResponse response = new AGSUpdateAchievementResponse (); response.error = error; response.userData = userData; response.achievementId = achievementId; return response; }
public static AGSUpdateAchievementResponse GetBlankResponseWithError(string error, string achievementId = "", int userData = 0) { AGSUpdateAchievementResponse response = new AGSUpdateAchievementResponse(); response.error = error; response.userData = userData; response.achievementId = achievementId; return(response); }
private void OnUpdateAchievementCompleted(AGSUpdateAchievementResponse response) { Action <bool> callback = simpleCallbacks.ContainsKey(response.userData) ? simpleCallbacks[response.userData] : null; if (null != callback) { callback(!response.IsError()); } simpleCallbacks.Remove(response.userData); }
/// <summary> /// callback method for native code to communicate events back to unity /// </summary> public static void UpdateAchievementSucceeded(string json) { AGSUpdateAchievementResponse response = AGSUpdateAchievementResponse.FromJSON(json); if (!response.IsError() && UpdateAchievementSucceededEvent != null) { UpdateAchievementSucceededEvent(response.achievementId); } if (UpdateAchievementCompleted != null) { UpdateAchievementCompleted(response); } }
public static AGSUpdateAchievementResponse FromJSON(string json) { try { AGSUpdateAchievementResponse response = new AGSUpdateAchievementResponse (); Hashtable hashtable = json.hashtableFromJson(); response.error = hashtable.ContainsKey("error") ? hashtable ["error"].ToString () : ""; response.userData = hashtable.ContainsKey("userData") ? int.Parse(hashtable ["userData"].ToString ()) : 0; response.achievementId = hashtable.ContainsKey("achievementId") ? hashtable ["achievementId"].ToString() : ""; return response; } catch (Exception e){ AGSClient.LogGameCircleError(e.ToString()); return GetBlankResponseWithError(JSON_PARSE_ERROR); } }
public static AGSUpdateAchievementResponse FromJSON(string json) { try { AGSUpdateAchievementResponse response = new AGSUpdateAchievementResponse(); Hashtable hashtable = json.hashtableFromJson(); response.error = hashtable.ContainsKey("error") ? hashtable ["error"].ToString() : ""; response.userData = hashtable.ContainsKey("userData") ? int.Parse(hashtable ["userData"].ToString()) : 0; response.achievementId = hashtable.ContainsKey("achievementId") ? hashtable ["achievementId"].ToString() : ""; return(response); } catch (Exception e) { AGSClient.LogGameCircleError(e.ToString()); return(GetBlankResponseWithError(JSON_PARSE_ERROR)); } }
private void OnUpdateAchievementCompleted(AGSUpdateAchievementResponse response) { if (response.IsError()) { AMN_UpdateAchievementResult result = new AMN_UpdateAchievementResult(response.achievementId, response.error); OnUpdateAchievementReceived(result); } else { AMN_UpdateAchievementResult result = new AMN_UpdateAchievementResult(response.achievementId); OnUpdateAchievementReceived(result); } }
#pragma warning disable 0618 /// <summary> /// updates an achievement /// </summary> /// <remarks> /// If a value outside of range is submitted, it is capped at 100 or 0. /// If submitted value is less than the stored value, the update is ignored. /// </remarks> /// <param name="achievementId">the id of the achievement to update</param> /// <param name="percentComplete">a float between 0.0f and 100.0f</param> /// <param name="userData"> /// ANDROID ONLY /// An optional code that will be returned in the response. Used to associate a function call to its response. /// A value of 0 is not recommended because 0 is the value returned when userData is not specified. /// </param> public static void UpdateAchievementProgress(string achievementId, float progress, int userData = 0) { #if UNITY_EDITOR && (UNITY_ANDROID || UNITY_IOS) // GameCircle only functions on device. #elif UNITY_ANDROID JavaObject.Call("updateAchievementProgress", achievementId, progress, userData); #else AGSUpdateAchievementResponse response = AGSUpdateAchievementResponse.GetPlatformNotSupportedResponse(achievementId, userData); if (UpdateAchievementFailedEvent != null) { UpdateAchievementFailedEvent(response.achievementId, response.error); } if (UpdateAchievementCompleted != null) { UpdateAchievementCompleted(response); } #endif }
private void OnUpdateAchievementCompleted( AGSUpdateAchievementResponse response ) { Action<bool> callback = simpleCallbacks.ContainsKey(response.userData) ? simpleCallbacks[response.userData] : null; if (null != callback) { callback(!response.IsError()); } simpleCallbacks.Remove (response.userData); }
private void OnUpdateAchievementCompleted( AGSUpdateAchievementResponse response ) { if (response.IsError()) { // Update the achievement submission status to show the error. achievementsSubmissionStatus[response.achievementId] = string.Format(achievementFailedLabel, response.achievementId); achievementsSubmissionStatusMessage[response.achievementId] = response.error; } else { // Update the status message to show that achievement submission was successful. achievementsSubmissionStatus[response.achievementId] = string.Format(achievementSucceededLabel, response.achievementId); } }