RoleInfoManager.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using FairyGUI;
  2. using ET;
  3. using System.Collections.Generic;
  4. using System;
  5. namespace GFGGame
  6. {
  7. public class RoleInfoManager : SingletonBase<RoleInfoManager>
  8. {
  9. public void Clear()
  10. {
  11. _headDatas.Clear();
  12. _headBorderDatas.Clear();
  13. }
  14. private List<int> _headDatas = new List<int>();
  15. public List<int> headDatas
  16. {
  17. get
  18. {
  19. SortHeadDatas();
  20. return _headDatas;
  21. }
  22. }
  23. private List<int> _headBorderDatas = new List<int>();
  24. public List<int> headBorderDatas
  25. {
  26. get
  27. {
  28. SortHeadBorderDatas();
  29. return _headBorderDatas;
  30. }
  31. }
  32. public void Add(int itemId)
  33. {
  34. ItemCfg cfg = ItemCfgArray.Instance.GetCfg(itemId);
  35. if (cfg.subType == 0)
  36. {
  37. if (_headDatas.IndexOf(itemId) < 0) _headDatas.Add(itemId);
  38. }
  39. else if (cfg.subType == 1)
  40. {
  41. if (_headBorderDatas.IndexOf(itemId) < 0) _headBorderDatas.Add(itemId);
  42. }
  43. }
  44. public void Remove(int itemId)
  45. {
  46. ItemCfg cfg = ItemCfgArray.Instance.GetCfg(itemId);
  47. if (cfg.subType == 0)
  48. {
  49. if (_headDatas.IndexOf(itemId) >= 0) _headDatas.Remove(itemId);
  50. }
  51. else if (cfg.subType == 1)
  52. {
  53. if (_headBorderDatas.IndexOf(itemId) >= 0) _headBorderDatas.Remove(itemId);
  54. }
  55. }
  56. private List<int> _newHeadDatas = new List<int>();
  57. private List<int> _newHeadBorderDatas = new List<int>();
  58. public void AddNew(int itemId)
  59. {
  60. ItemCfg cfg = ItemCfgArray.Instance.GetCfg(itemId);
  61. if (cfg.subType == 0)
  62. {
  63. if (_newHeadDatas.IndexOf(itemId) >= 0) _newHeadDatas.Add(itemId);
  64. }
  65. else if (cfg.subType == 1)
  66. {
  67. if (_newHeadBorderDatas.IndexOf(itemId) >= 0) _newHeadBorderDatas.Add(itemId);
  68. }
  69. }
  70. public void RemoveNew(int itemId)
  71. {
  72. ItemCfg cfg = ItemCfgArray.Instance.GetCfg(itemId);
  73. if (cfg.subType == 0)
  74. {
  75. if (_newHeadDatas.IndexOf(itemId) >= 0) _newHeadDatas.Remove(itemId);
  76. }
  77. else if (cfg.subType == 1)
  78. {
  79. if (_newHeadBorderDatas.IndexOf(itemId) >= 0) _newHeadBorderDatas.Remove(itemId);
  80. }
  81. }
  82. private void SortHeadDatas()
  83. {
  84. _headDatas.Sort((int a, int b) =>
  85. {
  86. if (a == RoleDataManager.headId && b != RoleDataManager.headId) return a - b;
  87. if (a != RoleDataManager.headId && b == RoleDataManager.headId) return b - a;
  88. if (_newHeadDatas.IndexOf(a) >= 0 && _newHeadDatas.IndexOf(b) < 0) return a - b;
  89. if (_newHeadDatas.IndexOf(a) < 0 && _newHeadDatas.IndexOf(b) >= 0) return b - a;
  90. return b - a;
  91. });
  92. }
  93. private void SortHeadBorderDatas()
  94. {
  95. _headBorderDatas.Sort((int a, int b) =>
  96. {
  97. return b - a;
  98. });
  99. }
  100. public decimal GetGuideProgress()
  101. {
  102. int suitHaveCount = 0;
  103. int suitTotalCount = 1;
  104. DressUpMenuSuitDataManager.GetTotalProgress(out suitHaveCount, out suitTotalCount);
  105. int chapterItemHaveCount = 0;
  106. int chapterItemTotalCount = 1;
  107. InstanceZonesDataManager.GetTotalProgress(out chapterItemHaveCount, out chapterItemTotalCount);
  108. int travelHaveCount = 0;
  109. int travelTotalCount = 1;
  110. TravelDataManager.Instance.GetTotalTravelProgress(out travelHaveCount, out travelTotalCount);
  111. int haveCount = suitHaveCount + chapterItemHaveCount + travelHaveCount;
  112. int totalCount = suitTotalCount + chapterItemTotalCount + travelTotalCount;
  113. decimal value = Math.Floor((decimal)100 * haveCount / totalCount);
  114. return value;
  115. }
  116. }
  117. }