using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TMPro; using KairoEngine.UI.Encyclopedia; using Sirenix.OdinInspector; namespace KairoEngine.Achievements { [HideMonoScript] public class AchievementEncyclopediaArticleUi : MonoBehaviour, IEncyclopediaArticleDataView { public Image iconContainer; public TextMeshProUGUI titleText; public TextMeshProUGUI descriptionText; public Slider progressBar; public Color unlockedTextColor = Color.white; public Color lockedTextColor = Color.gray; public void Setup(EncyclopediaArticle article) { article.booleans.TryGetValue("unlocked", out bool unlocked); if(unlocked) { titleText.color = unlockedTextColor; descriptionText.color = unlockedTextColor; } else { titleText.color = lockedTextColor; descriptionText.color = lockedTextColor; } article.booleans.TryGetValue("use-statistic", out bool useStatistic); iconContainer.sprite = article.icon; titleText.text = article.title; descriptionText.text = article.description; if(progressBar != null && useStatistic) { progressBar.gameObject.SetActive(true); article.integers.TryGetValue("current-value", out int value); article.integers.TryGetValue("max-value", out int max); if(value > max) value = max; progressBar.maxValue = max; progressBar.value = value; } else progressBar.gameObject.SetActive(false); } } }