AchievementsEncyclopediaCategory.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using KairoEngine.UI.Encyclopedia;
  5. using Sirenix.OdinInspector;
  6. namespace KairoEngine.Achievements
  7. {
  8. public class AchievementsEncyclopediaCategory : EncyclopediaCategory
  9. {
  10. public AchievementsController achievementsController;
  11. private List<EncyclopediaArticle> data = new List<EncyclopediaArticle>();
  12. private void Start()
  13. {
  14. if(achievementsController == null) achievementsController = FindObjectOfType<AchievementsController>();
  15. if(achievementsController == null) Debug.LogError("Missing Achievements Controller", this.gameObject);
  16. }
  17. public override List<EncyclopediaArticle> GetArticles()
  18. {
  19. UpdateArticles();
  20. return data;
  21. }
  22. public override void UpdateArticles()
  23. {
  24. data = new List<EncyclopediaArticle>();
  25. if(achievementsController == null) return;
  26. foreach (AchievementStatus item in achievementsController.achievementsStatus)
  27. {
  28. var article = item.achievement.GetArticle();
  29. article.id = id + "_" + article.id;
  30. article.unlocked = item.unlocked;
  31. data.Add(article);
  32. }
  33. }
  34. }
  35. }