/// <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); }
/// <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); }
/// <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); }
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); }
/// <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); }
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 }
public void SubmitAchievement(string achievementId, float progress) { // Submit the achievement update to the GameCircle plugin. AGSAchievementsClient.UpdateAchievementProgress(achievementId, progress); }
/// <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++); }
//submit progress public void UpdateAchievementProgress(string achieve_id, float score) { #if AMAZON_CIRCLE_ENABLED AGSAchievementsClient.UpdateAchievementProgress(achieve_id, score); #endif }