RoleInfoManager.cs 4.7 KB

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