public static void Unlock(Achievement a) { // Don't allow double-granting of achievements if(a.IsUnlocked) return; a.IsUnlocked = true; ShowAchievementUnlocked(a); }
private static void ShowAchievementUnlocked(Achievement a) { var content = new GUIContent("ACHIEVEMENT UNLOCKED\n" + a.Title, GetIcon ()); // Find the best window to display this on var allWindows = new HashSet<EditorWindow>((EditorWindow[])Resources.FindObjectsOfTypeAll(typeof(EditorWindow))); allWindows.RemoveWhere (IsEditorWindowHiddenTab); var targetWindow = allWindows.OrderByDescending(w => Mathf.Pow(w.position.width, WidthBias) * w.position.height).FirstOrDefault(); if(targetWindow) { targetWindow.ShowNotification(content); } Debug.Log (string.Format("ACHIEVEMENT UNLOCKED: {0}\n{1}\n\n\n\n\n", a.Title, a.Description)); }
public static void Register(Achievement a) { if(_registeredAchievements == null) _registeredAchievements = new List<Achievement>(); _registeredAchievements.Add (a); }