AchievementsEncyclopediaCategory.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. if(achievementsController.achievementsStatus == null) return;
  27. foreach (AchievementStatus item in achievementsController.achievementsStatus)
  28. {
  29. var article = item.achievement.GetArticle();
  30. article.id = id + "_" + article.id;
  31. article.unlocked = item.unlocked;
  32. data.Add(article);
  33. }
  34. }
  35. }
  36. }