SuitSyntheticView.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. using System.Collections;
  2. using UnityEngine;
  3. using UI.ClothingSynthetic;
  4. using FairyGUI;
  5. using System.Collections.Generic;
  6. namespace GFGGame
  7. {
  8. public class SuitSyntheticView : BaseView
  9. {
  10. private UI_ClothingSyntheticListUI _ui;
  11. private List<int> _suitListIds;
  12. public override void Dispose()
  13. {
  14. if (_ui != null)
  15. {
  16. _ui.Dispose();
  17. _ui = null;
  18. }
  19. base.Dispose();
  20. }
  21. protected override void OnInit()
  22. {
  23. base.OnInit();
  24. packageName = UI_ClothingSyntheticListUI.PACKAGE_NAME;
  25. _ui = UI_ClothingSyntheticListUI.Create();
  26. this.viewCom = _ui.target;
  27. isfullScreen = true;
  28. isReturnView = true;
  29. _ui.m_listSuit.itemRenderer = ListSuitItemRenderer;
  30. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  31. _ui.m_listMenu.onClickItem.Add(OnClickListMenuItem);
  32. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("hz_bjbj");
  33. }
  34. protected override void AddEventListener()
  35. {
  36. base.AddEventListener();
  37. EventAgent.AddEventListener(ConstMessage.SUIT_BOX_STATUS_CHANGED, UpdateSuitBoxStatus);
  38. EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  39. EventAgent.AddEventListener(ConstMessage.CLOTHING_SYNTHETIC_SUCCESS, UpdateSuitList);
  40. }
  41. protected override void OnShown()
  42. {
  43. base.OnShown();
  44. _ui.m_listMenu.selectedIndex = 0;
  45. if (this.viewData != null)
  46. {
  47. int suitId = (int)this.viewData;
  48. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
  49. _ui.m_listMenu.selectedIndex = suitCfg.syntheticType - 1;
  50. }
  51. // _ui.m_listMenu.GetChildAt(1).visible = false;
  52. UpdateSuitList();
  53. UpdateRedDot();
  54. //Timers.inst.AddUpdate(CheckGuide);
  55. }
  56. protected override void OnHide()
  57. {
  58. base.OnHide();
  59. //Timers.inst.Remove(CheckGuide);
  60. }
  61. protected override void RemoveEventListener()
  62. {
  63. base.RemoveEventListener();
  64. EventAgent.RemoveEventListener(ConstMessage.SUIT_BOX_STATUS_CHANGED, UpdateSuitBoxStatus);
  65. EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
  66. EventAgent.RemoveEventListener(ConstMessage.CLOTHING_SYNTHETIC_SUCCESS, UpdateSuitList);
  67. }
  68. private void OnClickBtnBack()
  69. {
  70. ViewManager.GoBackFrom(typeof(SuitSyntheticView).FullName);
  71. }
  72. private void OnClickListMenuItem()
  73. {
  74. UpdateSuitList();
  75. }
  76. private void UpdateSuitList()
  77. {
  78. if (_suitListIds == null)
  79. {
  80. _suitListIds = new List<int>();
  81. }
  82. else
  83. {
  84. _suitListIds.Clear();
  85. }
  86. int index = _ui.m_listMenu.selectedIndex;
  87. var suitCfgs = SuitCfgArray.Instance.GetCfgsBysyntheticType(index + 1);
  88. foreach (var suitCfg in suitCfgs)
  89. {
  90. _suitListIds.Add(suitCfg.id);
  91. }
  92. _ui.m_listSuit.numItems = _suitListIds.Count;
  93. }
  94. private void ListSuitItemRenderer(int index, GObject item)
  95. {
  96. UI_SuitListItem listItem = UI_SuitListItem.Proxy(item);
  97. int suitId = _suitListIds[index];
  98. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
  99. listItem.m_txtName.text = suitCfg.name;
  100. listItem.m_loaderPic.url = ResPathUtil.GetFieldGuideIconPath(suitCfg.res);
  101. int count = 0;
  102. int totalCount = 0;
  103. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitId, out count, out totalCount);
  104. listItem.m_progBar.max = totalCount;
  105. listItem.m_progBar.value = count;
  106. RarityIconController.UpdateRarityIcon(listItem.m_rarity, suitId, false, true);
  107. bool haveSuit = DressUpMenuSuitDataManager.CheckHaveSuit(suitId);
  108. bool isLock = false;
  109. // SuitCfg suitSyntheticCfg = SuitCfgArray.Instance.GetCfg(suitId);
  110. if (suitCfg.syntheticStoryLevelId > 0)
  111. {
  112. //int chapter = 0;
  113. //int level = 0;
  114. //CalculateHelper.GetStoryChapterLevel(suitSyntheticCfg.storyLevelId, out var chapter, out var level);
  115. bool isLevelPass = InstanceZonesDataManager.CheckLevelPass(suitCfg.syntheticStoryLevelId);
  116. if (!isLevelPass)
  117. {
  118. isLock = true;
  119. var levelCfg = StoryLevelCfgArray.Instance.GetCfg(suitCfg.syntheticStoryLevelId);
  120. string str = "";
  121. if (levelCfg.type == ConstInstanceZonesType.Studio && levelCfg.subType == ConstInstanceZonesSubType.Hard3)
  122. {
  123. StoryLevelCfg cfg = StoryLevelCfgArray.Instance.GetCfg(suitCfg.syntheticStoryLevelId);
  124. str = string.Format("通关查阅建档 {0}", cfg.name);
  125. }
  126. else
  127. {
  128. var chapterCfg = StoryChapterCfgArray.Instance.GetCfg(levelCfg.chapterId);
  129. str = string.Format("通关第{0}章第{1}关", chapterCfg.order, levelCfg.order);
  130. }
  131. listItem.m_txtLockDesc.text = str;
  132. }
  133. }
  134. if (suitCfg.syntheticPreSuitId > 0)
  135. {
  136. bool hasPreSuit = DressUpMenuSuitDataManager.CheckHaveSuit(suitCfg.syntheticPreSuitId);
  137. if (!hasPreSuit)
  138. {
  139. isLock = true;
  140. string preSuitName = SuitUtil.GetSuitName(suitCfg.syntheticPreSuitId);
  141. listItem.m_txtLockDesc.text = string.Format("集齐{0}套装", preSuitName);
  142. }
  143. }
  144. listItem.m_groupLock.visible = isLock;
  145. listItem.target.data = suitId;
  146. UpdateSuitBoxStatusView(listItem);
  147. int status = DressUpMenuSuitDataManager.GetSuitSyntheticBonusStatus(suitId);
  148. RedDotController.Instance.SetComRedDot(listItem.target, status == ConstBonusStatus.CAN_GET && !isLock, "", -20, 670);
  149. listItem.m_loaderBonusBox.onClick.Clear();
  150. listItem.m_loaderBonusBox.onClick.Add(() =>
  151. {
  152. SuitUtil.ShowSuitSyntheticBonus(suitId);
  153. });
  154. listItem.m_bg.onClick.Clear();
  155. listItem.m_bg.onClick.Add(() =>
  156. {
  157. if (!isLock)
  158. {
  159. ViewManager.Show<ClothingSyntheticView>(new object[] { suitId }, new object[] { typeof(SuitSyntheticView).FullName, suitId });
  160. }
  161. });
  162. RedDotController.Instance.SetComRedDot(listItem.target, RedDotDataManager.Instance.GetClothingSyntheticRed(suitId), "", 0, 0);
  163. UI_SuitListItem.ProxyEnd();
  164. }
  165. private void UpdateSuitBoxStatus(EventContext eventContext)
  166. {
  167. int suitId = (int)eventContext.data;
  168. int num = _ui.m_listSuit.numChildren;
  169. for (int i = 0; i < num; i++)
  170. {
  171. UI_SuitListItem listItem = UI_SuitListItem.Proxy(_ui.m_listSuit.GetChildAt(i));
  172. int tempSuitId = (int)listItem.target.data;
  173. if (tempSuitId == suitId)
  174. {
  175. UpdateSuitBoxStatusView(listItem);
  176. }
  177. UI_SuitListItem.ProxyEnd();
  178. }
  179. }
  180. private void UpdateSuitBoxStatusView(UI_SuitListItem listItem)
  181. {
  182. listItem.m_iconGot.visible = false;
  183. int suitId = (int)listItem.target.data;
  184. int status = DressUpMenuSuitDataManager.GetSuitSyntheticBonusStatus(suitId);
  185. if (status == ConstBonusStatus.CAN_GET)
  186. {
  187. listItem.m_loaderBonusBox.grayed = false;
  188. }
  189. else
  190. {
  191. listItem.m_loaderBonusBox.grayed = true;
  192. if (status == ConstBonusStatus.GOT)
  193. {
  194. listItem.m_iconGot.visible = true;
  195. }
  196. RedDotController.Instance.SetComRedDot(listItem.target, false, "", -20, 670);
  197. }
  198. }
  199. private void UpdateRedDot()
  200. {
  201. RedDotController.Instance.SetComRedDot(_ui.m_listMenu.GetChildAt(0).asCom, RedDotDataManager.Instance.GetClothingSyntheticTabRed(1), "", 0, 0);
  202. RedDotController.Instance.SetComRedDot(_ui.m_listMenu.GetChildAt(1).asCom, RedDotDataManager.Instance.GetClothingSyntheticTabRed(2), "", 0, 0);
  203. RedDotController.Instance.SetComRedDot(_ui.m_listMenu.GetChildAt(2).asCom, RedDotDataManager.Instance.GetClothingSyntheticTabRed(3), "", 0, 0);
  204. }
  205. private void CheckGuide(object param)
  206. {
  207. if (GuideDataManager.IsGuideFinish(ConstGuideId.CLOTHING_SYNTHETIC) <= 0)
  208. {
  209. UpdateToCheckGuide(null);
  210. }
  211. else
  212. {
  213. Timers.inst.Remove(CheckGuide);
  214. }
  215. }
  216. protected override void UpdateToCheckGuide(object param)
  217. {
  218. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  219. int suitId = 200042;
  220. int suitIndex = 0;
  221. for (int i = 0; i < _suitListIds.Count; i++)
  222. {
  223. if (_suitListIds[i] == suitId)
  224. {
  225. suitIndex = i;
  226. break;
  227. }
  228. }
  229. //GuideController.TryGuide(_ui.m_listSuit, ConstGuideId.CLOTHING_SYNTHETIC, 3, "查看已解锁的图谱。", suitIndex);
  230. }
  231. }
  232. }