RoleInfoManager.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. private List<long> _photoDatas = new List<long>() { 0, 0, 0, 0 };
  33. public List<long> photoDatas
  34. {
  35. get
  36. {
  37. return _photoDatas;
  38. }
  39. set
  40. {
  41. _photoDatas = value;
  42. }
  43. }
  44. public void Add(int itemId)
  45. {
  46. ItemCfg cfg = ItemCfgArray.Instance.GetCfg(itemId);
  47. if (cfg.subType == 0)
  48. {
  49. if (_headDatas.IndexOf(itemId) < 0) _headDatas.Add(itemId);
  50. }
  51. else if (cfg.subType == 1)
  52. {
  53. if (_headBorderDatas.IndexOf(itemId) < 0) _headBorderDatas.Add(itemId);
  54. }
  55. }
  56. public void Remove(int itemId)
  57. {
  58. ItemCfg cfg = ItemCfgArray.Instance.GetCfg(itemId);
  59. if (cfg.subType == 0)
  60. {
  61. if (_headDatas.IndexOf(itemId) >= 0) _headDatas.Remove(itemId);
  62. }
  63. else if (cfg.subType == 1)
  64. {
  65. if (_headBorderDatas.IndexOf(itemId) >= 0) _headBorderDatas.Remove(itemId);
  66. }
  67. }
  68. private List<int> _newHeadDatas = new List<int>();
  69. private List<int> _newHeadBorderDatas = new List<int>();
  70. public void AddNew(int itemId)
  71. {
  72. ItemCfg cfg = ItemCfgArray.Instance.GetCfg(itemId);
  73. if (cfg.subType == 0)
  74. {
  75. if (_newHeadDatas.IndexOf(itemId) >= 0) _newHeadDatas.Add(itemId);
  76. }
  77. else if (cfg.subType == 1)
  78. {
  79. if (_newHeadBorderDatas.IndexOf(itemId) >= 0) _newHeadBorderDatas.Add(itemId);
  80. }
  81. }
  82. public void RemoveNew(int itemId)
  83. {
  84. ItemCfg cfg = ItemCfgArray.Instance.GetCfg(itemId);
  85. if (cfg.subType == 0)
  86. {
  87. if (_newHeadDatas.IndexOf(itemId) >= 0) _newHeadDatas.Remove(itemId);
  88. }
  89. else if (cfg.subType == 1)
  90. {
  91. if (_newHeadBorderDatas.IndexOf(itemId) >= 0) _newHeadBorderDatas.Remove(itemId);
  92. }
  93. }
  94. private void SortHeadDatas()
  95. {
  96. _headDatas.Sort((int a, int b) =>
  97. {
  98. if (a == RoleDataManager.headId && b != RoleDataManager.headId) return a - b;
  99. if (a != RoleDataManager.headId && b == RoleDataManager.headId) return b - a;
  100. if (_newHeadDatas.IndexOf(a) >= 0 && _newHeadDatas.IndexOf(b) < 0) return a - b;
  101. if (_newHeadDatas.IndexOf(a) < 0 && _newHeadDatas.IndexOf(b) >= 0) return b - a;
  102. return b - a;
  103. });
  104. }
  105. private void SortHeadBorderDatas()
  106. {
  107. _headBorderDatas.Sort((int a, int b) =>
  108. {
  109. return b - a;
  110. });
  111. }
  112. public decimal GetGuideProgress()
  113. {
  114. int suitHaveCount = 0;
  115. int suitTotalCount = 1;
  116. DressUpMenuSuitDataManager.GetTotalProgress(out suitHaveCount, out suitTotalCount);
  117. int chapterItemHaveCount = 0;
  118. int chapterItemTotalCount = 1;
  119. InstanceZonesDataManager.GetTotalProgress(out chapterItemHaveCount, out chapterItemTotalCount);
  120. int travelHaveCount = 0;
  121. int travelTotalCount = 1;
  122. TravelDataManager.Instance.GetTotalTravelProgress(out travelHaveCount, out travelTotalCount);
  123. int haveCount = suitHaveCount + chapterItemHaveCount + travelHaveCount;
  124. int totalCount = suitTotalCount + chapterItemTotalCount + travelTotalCount;
  125. decimal value = Math.Floor((decimal)100 * haveCount / totalCount);
  126. return value;
  127. }
  128. }
  129. }