/// <summary> /// Display the achievement Popup and play a boop /// </summary> /// <param name="achievement"></param> public void ShowAchievementGrant(Achievement achievement) { audioSource.Play(); achievementPopup.SetAchievementValues(achievement); }
void DrawAchievementsArea() { EditorGUILayout.LabelField('\u2630' + " Achievements", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(EditorStyles.helpBox); scrollStart = EditorGUILayout.BeginScrollView(scrollStart); for (int i = 0; i < tempAchievementList.Count; i++) { Achievement achievement = tempAchievementList[i]; // Grab the icon based on the saved asset path (so we can generate an instanceID for the editor) achievement.icon = (Sprite)AssetDatabase.LoadAssetAtPath(achievement.iconPath, typeof(Sprite)); showAchievementDetails.Add(false); showAchievementDetails[i] = EditorGUILayout.Foldout(showAchievementDetails[i], achievement.title); if (showAchievementDetails[i]) { GUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(new GUIContent("Icon", "Icon used to represent the achievement in the UI")); if (achievement.iconPath != "") { achievement.icon = (Sprite)EditorGUILayout.ObjectField("", AssetDatabase.LoadAssetAtPath <Sprite>(achievement.iconPath), typeof(Sprite), true); } else { achievement.icon = (Sprite)EditorGUILayout.ObjectField("", achievement.icon, typeof(Sprite), true); } achievement.iconPath = AssetDatabase.GetAssetPath(achievement.icon); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(new GUIContent("ID", "Unique identifier used to reference specific achievements (must be unique!)")); achievement.id = EditorGUILayout.IntField(achievement.id); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(new GUIContent("Name", "Achievement's title displayed in the UI")); achievement.title = EditorGUILayout.TextField(achievement.title); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(new GUIContent("Description", "Summary text displayed below the achievevement title")); achievement.description = EditorGUILayout.TextArea(achievement.description); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(new GUIContent("Needed Value", "The needed incremental amount to complete achievement")); achievement.neededValue = EditorGUILayout.IntField(achievement.neededValue); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(new GUIContent("Current Value", "The amount of progress currently made")); achievement.value = EditorGUILayout.IntSlider(achievement.value, 0, achievement.neededValue); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(new GUIContent("Display as Percentage", "If checked, the achievement values will display as {value}%")); achievement.displayAsPercentage = EditorGUILayout.Toggle(achievement.displayAsPercentage); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(new GUIContent("Reward Value", "The amount of achievement points to grant when completed")); achievement.points = EditorGUILayout.IntField(achievement.points); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(new GUIContent("Completed", "Whether or not the achievement is completed")); achievement.completed = EditorGUILayout.Toggle(achievement.completed); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(new GUIContent("Secretive", "Secretive achievement details are hidden in the UI until completed")); achievement.secret = EditorGUILayout.Toggle(achievement.secret); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("▲", "Move up list"), GUILayout.Width(30)) && i > 0) { int desiredIndex = i - 1; var item = achievement; tempAchievementList.RemoveAt(i); tempAchievementList.Insert(desiredIndex, item); showAchievementDetails[desiredIndex] = true; showAchievementDetails[i] = false; } else if (GUILayout.Button(new GUIContent("▼", "Move down list"), GUILayout.Width(30)) && i < tempAchievementList.Count - 1) { int desiredIndex = i + 1; var item = achievement; tempAchievementList.RemoveAt(i); tempAchievementList.Insert(desiredIndex, item); showAchievementDetails[desiredIndex] = true; showAchievementDetails[i] = false; } GUI.color = new Color32(255, 145, 165, 255); if (GUILayout.Button(new GUIContent("✖", "Remove achievement"), GUILayout.Width(20))) { tempAchievementList.RemoveAt(i); showAchievementDetails.RemoveAt(i); ++i; } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); GUILayout.EndVertical(); } } EditorGUILayout.EndScrollView(); GUI.color = new Color32(229, 243, 255, 255); EditorGUILayout.EndVertical(); }
/// <summary> /// Update the achievement list's point display /// </summary> public void UpdateScore(Achievement achievement) { currentAchievementScore.text = AchievementController.CurrentAchievementScore.ToString() + " Points"; }