/// <summary> /// Sets the progress of the specified achievement (if found) to the specified progress. /// </summary> /// <param name="achievementID">Achievement ID.</param> /// <param name="newProgress">New progress.</param> public static void SetProgress(string achievementID, int newProgress) { _achievement = AchievementManagerContains(achievementID); if (_achievement != null) { _achievement.SetProgress(newProgress); } }
/// <summary> /// Copies this achievement (useful when loading from a scriptable object list) /// </summary> public virtual MMAchievement Copy() { MMAchievement clone = new MMAchievement(); // we use Json utility to store a copy of our achievement, not a reference clone = JsonUtility.FromJson <MMAchievement>(JsonUtility.ToJson(this)); return(clone); }
/// <summary> /// Locks the specified achievement (if found). /// </summary> /// <param name="achievementID">Achievement ID.</param> public static void LockAchievement(string achievementID) { _achievement = AchievementManagerContains(achievementID); if (_achievement != null) { _achievement.LockAchievement(); } }
/// <summary> /// Instantiates an achievement display prefab and shows it for the specified duration /// </summary> /// <returns>The achievement.</returns> /// <param name="achievement">Achievement.</param> public virtual IEnumerator DisplayAchievement(MMAchievement achievement) { if ((this.transform == null) || (AchievementDisplayPrefab == null)) { yield break; } // we instantiate our achievement display prefab, and add it to the group that will automatically handle its position GameObject instance = (GameObject)Instantiate(AchievementDisplayPrefab.gameObject); instance.transform.SetParent(this.transform, false); // we get the achievement displayer MMAchievementDisplayItem achievementDisplay = instance.GetComponent <MMAchievementDisplayItem> (); if (achievementDisplay == null) { yield break; } // we fill our achievement achievementDisplay.Title.text = achievement.Title; achievementDisplay.Description.text = achievement.Description; achievementDisplay.Icon.sprite = achievement.UnlockedImage; if (achievement.AchievementType == AchievementTypes.Progress) { achievementDisplay.ProgressBarDisplay.gameObject.SetActive(true); } else { achievementDisplay.ProgressBarDisplay.gameObject.SetActive(false); } // we play a sound if set if (achievement.UnlockedSound != null) { MMSfxEvent.Trigger(achievement.UnlockedSound); } // we fade it in and out CanvasGroup achievementCanvasGroup = instance.GetComponent <CanvasGroup> (); if (achievementCanvasGroup != null) { achievementCanvasGroup.alpha = 0; StartCoroutine(MMFade.FadeCanvasGroup(achievementCanvasGroup, AchievementFadeDuration, 1)); yield return(_achievementFadeOutWFS); StartCoroutine(MMFade.FadeCanvasGroup(achievementCanvasGroup, AchievementFadeDuration, 0)); } }
/// <summary> /// Constructor /// </summary> /// <param name="newAchievement">New achievement.</param> public MMAchievementUnlockedEvent(MMAchievement newAchievement) { Achievement = newAchievement; }
public static void Trigger(MMAchievement newAchievement) { e.Achievement = newAchievement; MMEventManager.TriggerEvent(e); }
/// <summary> /// Constructor /// </summary> /// <param name="newAchievement">New achievement.</param> public MMAchievementChangedEvent(MMAchievement newAchievement) { Achievement = newAchievement; }