RoleInfoManager.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. _newHeadDatas.Clear();
  15. _newHeadBorderDatas.Clear();
  16. }
  17. private List<int> _headDatas = new List<int>();
  18. public List<int> headDatas
  19. {
  20. get
  21. {
  22. return _headDatas;
  23. }
  24. }
  25. private List<int> _headBorderDatas = new List<int>();
  26. public List<int> headBorderDatas
  27. {
  28. get
  29. {
  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)
  39. {
  40. _headDatas.Add(itemId);
  41. }
  42. }
  43. else if (cfg.subType == 1)
  44. {
  45. if (_headBorderDatas.IndexOf(itemId) < 0)
  46. {
  47. _headBorderDatas.Add(itemId);
  48. }
  49. }
  50. }
  51. public void Remove(int itemId)
  52. {
  53. ItemCfg cfg = ItemCfgArray.Instance.GetCfg(itemId);
  54. if (cfg.subType == 0)
  55. {
  56. if (_headDatas.IndexOf(itemId) >= 0) _headDatas.Remove(itemId);
  57. }
  58. else if (cfg.subType == 1)
  59. {
  60. if (_headBorderDatas.IndexOf(itemId) >= 0) _headBorderDatas.Remove(itemId);
  61. }
  62. }
  63. private List<int> _newHeadDatas = new List<int>();
  64. public List<int> newHeadDatas
  65. {
  66. get
  67. {
  68. return _newHeadDatas;
  69. }
  70. }
  71. private List<int> _newHeadBorderDatas = new List<int>();
  72. public List<int> newHeadBorderDatas
  73. {
  74. get
  75. {
  76. return _newHeadBorderDatas;
  77. }
  78. }
  79. public void AddNew(int itemId)
  80. {
  81. ItemCfg cfg = ItemCfgArray.Instance.GetCfg(itemId);
  82. if (cfg.subType == 0)
  83. {
  84. if (_newHeadDatas.IndexOf(itemId) < 0) _newHeadDatas.Add(itemId);
  85. }
  86. else if (cfg.subType == 1)
  87. {
  88. if (_newHeadBorderDatas.IndexOf(itemId) < 0) _newHeadBorderDatas.Add(itemId);
  89. }
  90. }
  91. public void RemoveNew(int itemId)
  92. {
  93. ItemCfg cfg = ItemCfgArray.Instance.GetCfg(itemId);
  94. if (cfg.subType == 0)
  95. {
  96. if (_newHeadDatas.IndexOf(itemId) >= 0) _newHeadDatas.Remove(itemId);
  97. }
  98. else if (cfg.subType == 1)
  99. {
  100. if (_newHeadBorderDatas.IndexOf(itemId) >= 0) _newHeadBorderDatas.Remove(itemId);
  101. }
  102. }
  103. public bool isNewHead(int itemId)
  104. {
  105. return _newHeadDatas.IndexOf(itemId) >= 0;
  106. }
  107. public bool isNewHeadBorder(int itemId)
  108. {
  109. return _newHeadBorderDatas.IndexOf(itemId) >= 0;
  110. }
  111. public void SortHeadDatas()
  112. {
  113. _headDatas.Sort((int a, int b) =>
  114. {
  115. if (_newHeadDatas.IndexOf(a) >= 0) return -1;
  116. if (_newHeadDatas.IndexOf(b) >= 0) return 1;
  117. if (a == RoleDataManager.headId) return -1;
  118. if (b == RoleDataManager.headId) return 1;
  119. return b - a;
  120. });
  121. }
  122. public void SortHeadBorderDatas()
  123. {
  124. _headBorderDatas.Sort((int a, int b) =>
  125. {
  126. if (_newHeadBorderDatas.IndexOf(a) >= 0) return -1;
  127. if (_newHeadBorderDatas.IndexOf(b) >= 0) return 1;
  128. if (a == RoleDataManager.headBorderId) return -1;
  129. if (b == RoleDataManager.headBorderId) return 1;
  130. return b - a;
  131. });
  132. }
  133. public decimal GetGuideProgress()
  134. {
  135. int suitHaveCount = 0;
  136. int suitTotalCount = 1;
  137. DressUpMenuSuitDataManager.GetTotalProgress(out suitHaveCount, out suitTotalCount);
  138. // int chapterItemHaveCount = 0;
  139. // int chapterItemTotalCount = 1;
  140. // InstanceZonesDataManager.GetTotalProgress(out chapterItemHaveCount, out chapterItemTotalCount);
  141. // int travelHaveCount = 0;
  142. // int travelTotalCount = 1;
  143. // TravelDataManager.Instance.GetTotalTravelProgress(out travelHaveCount, out travelTotalCount);
  144. // int haveCount = suitHaveCount + chapterItemHaveCount + travelHaveCount;
  145. // int totalCount = suitTotalCount + chapterItemTotalCount + travelTotalCount;
  146. decimal value = Math.Floor((decimal)100 * suitHaveCount / suitTotalCount);
  147. return value;
  148. }
  149. public void UpdateHead(GComponent component, int roleId, int roleBorderId)
  150. {
  151. ItemCfg headCfg = ItemCfgArray.Instance.GetCfg(roleId == 0 ? ConstItemID.HEADID : roleId);
  152. ItemCfg headBorderCfg = ItemCfgArray.Instance.GetCfg(roleBorderId == 0 ? ConstItemID.HEADBORDERID : roleBorderId);
  153. UI_ComHead comHead = UI_ComHead.Proxy(component);
  154. comHead.m_comHead.m_loaIcon.url = ResPathUtil.GetHeadPath(headCfg.res);
  155. comHead.m_loaBorder.url = ResPathUtil.GetHeadBorderPath(headBorderCfg.res);
  156. UI_ComHead.ProxyEnd();
  157. }
  158. public void UpdateNpcHead(GComponent component, string res)
  159. {
  160. UI_ComHead comHead = UI_ComHead.Proxy(component);
  161. if (string.IsNullOrEmpty(res))
  162. {
  163. comHead.m_comHead.m_loaIcon.url = res;
  164. }
  165. else
  166. {
  167. comHead.m_comHead.m_loaIcon.url = ResPathUtil.GetNpcHeadPath(res);
  168. }
  169. UI_ComHead.ProxyEnd();
  170. }
  171. public void UpdateLv(GComponent component, int lv)
  172. {
  173. UI_ComLv comLv = UI_ComLv.Proxy(component);
  174. comLv.m_txtLvl.text = lv > 0 ? lv.ToString() : "--";
  175. UI_ComLv.ProxyEnd();
  176. }
  177. }
  178. }