ClothingListView.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. using System.Collections.Generic;
  2. using ET;
  3. using FairyGUI;
  4. using UI.ClothingFoster;
  5. namespace GFGGame
  6. {
  7. public class ClothingListView : BaseWindow
  8. {
  9. private UI_ClothingListUI _ui;
  10. private ValueBarController _valueBarController;
  11. private int _menuType = ConstSuitGuideTypeId.TYPE_1;
  12. private int[] _menuTypeDataArray;
  13. private List<int> _suitIds;
  14. public override void Dispose()
  15. {
  16. if (_ui != null)
  17. {
  18. _ui.Dispose();
  19. _ui = null;
  20. }
  21. base.Dispose();
  22. }
  23. protected override void OnInit()
  24. {
  25. base.OnInit();
  26. packageName = UI_ClothingListUI.PACKAGE_NAME;
  27. _ui = UI_ClothingListUI.Create();
  28. this.viewCom = _ui.target;
  29. isfullScreen = true;
  30. _valueBarController = new ValueBarController(_ui.m_valueBar);
  31. _ui.m_listSuit.itemRenderer = ListSuitItemRenderer;
  32. _ui.m_comBoxSort.items = new string[] { "默认排序", "稀有度高", "稀有度低", "收集度高", "收集度低" };
  33. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  34. _ui.m_comBoxSort.onChanged.Add(OnComboBoxSortChanged);
  35. _ui.m_btnHaveGot.onChanged.Add(OnClickBtnHaveGot);
  36. _ui.m_btnNotGet.onChanged.Add(OnClickBtnNotGet);
  37. }
  38. protected override void AddEventListener()
  39. {
  40. base.AddEventListener();
  41. EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, UpdateSuitStatus);
  42. }
  43. protected override void OnShown()
  44. {
  45. base.OnShown();
  46. _valueBarController.OnShown();
  47. _ui.m_btnHaveGot.selected = true;
  48. _ui.m_btnNotGet.selected = true;
  49. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gxhd_bjbj");
  50. SuitFosterProxy.SendGetSuitInfos().Coroutine();
  51. UpdateListSuit();
  52. Timers.inst.AddUpdate(CheckGuide);
  53. }
  54. protected override void OnHide()
  55. {
  56. base.OnHide();
  57. _valueBarController.OnHide();
  58. Timers.inst.Remove(CheckGuide);
  59. }
  60. protected override void RemoveEventListener()
  61. {
  62. base.RemoveEventListener();
  63. EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, UpdateSuitStatus);
  64. }
  65. private void OnClickBtnBack()
  66. {
  67. // this.Hide();
  68. ViewManager.GoBackFrom(typeof(ClothingListView).FullName);
  69. }
  70. private void OnClickListTypeItem()
  71. {
  72. UpdateListSuit();
  73. }
  74. private void OnComboBoxSortChanged()
  75. {
  76. UpdateListSuit();
  77. }
  78. private void OnClickBtnSwitch()
  79. {
  80. _menuType = 3 - _menuType;
  81. }
  82. private void OnClickBtnHaveGot()
  83. {
  84. if (!_ui.m_btnHaveGot.selected)
  85. {
  86. _ui.m_btnNotGet.selected = true;
  87. }
  88. UpdateListSuit();
  89. }
  90. private void OnClickBtnNotGet()
  91. {
  92. if (!_ui.m_btnNotGet.selected)
  93. {
  94. _ui.m_btnHaveGot.selected = true;
  95. }
  96. UpdateListSuit();
  97. }
  98. private void UpdateListSuit()
  99. {
  100. _ui.m_listSuit.RemoveChildrenToPool();
  101. _suitIds = SuitUtil.GetClothingFosterSuitIdList(_ui.m_btnNotGet.selected, _ui.m_btnHaveGot.selected, _ui.m_comBoxSort.selectedIndex);
  102. _ui.m_listSuit.numItems = _suitIds.Count;
  103. _ui.m_listSuit.scrollPane.ScrollTop();
  104. }
  105. private void ListSuitItemRenderer(int index, GObject item)
  106. {
  107. UI_ListSuitItem listItem = UI_ListSuitItem.Proxy(item);
  108. int suitId = _suitIds[index];
  109. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
  110. listItem.m_txtName.text = suitCfg.name;
  111. listItem.m_loaderPic.url = ResPathUtil.GetFieldGuideIconPath(suitCfg.res);
  112. RarityIconController.UpdateRarityIcon(listItem.m_rarity, suitId, false, true);
  113. listItem.target.data = suitId;
  114. UpdateSuitStatusView(listItem);
  115. UI_ListSuitItem.ProxyEnd();
  116. }
  117. private void UpdateSuitStatus(EventContext eventContext)
  118. {
  119. int num = _ui.m_listSuit.numChildren;
  120. for (int i = 0; i < num; i++)
  121. {
  122. UI_ListSuitItem listItem = UI_ListSuitItem.Proxy(_ui.m_listSuit.GetChildAt(i));
  123. UpdateSuitStatusView(listItem);
  124. UI_ListSuitItem.ProxyEnd();
  125. }
  126. }
  127. private void UpdateSuitStatusView(UI_ListSuitItem listItem)
  128. {
  129. int suitId = (int)listItem.target.data;
  130. int count = 0;
  131. int totalCount = 0;
  132. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitId, out count, out totalCount);
  133. listItem.m_progBar.max = totalCount;
  134. listItem.m_progBar.value = count;
  135. bool haveSuit = DressUpMenuSuitDataManager.CheckHaveSuit(suitId);
  136. listItem.m_imgLock.visible = listItem.m_imgLockBg.visible = !haveSuit;
  137. listItem.m_bg.onClick.Clear();
  138. listItem.m_bg.onClick.Add(() =>
  139. {
  140. if (haveSuit)
  141. {
  142. ViewManager.Show<ClothingView>(new object[] { suitId, _suitIds }, new object[] { typeof(ClothingListView).Name, this.viewData });
  143. }
  144. else
  145. {
  146. ViewManager.Show(ViewName.SUIT_PARTS_DETAIL_VIEW, suitId, new object[] { ViewName.SUIT_PARTS_DETAIL_VIEW, this.viewData });
  147. }
  148. });
  149. }
  150. private void CheckGuide(object param)
  151. {
  152. if (GuideDataManager.IsGuideFinish(ConstGuideId.SUIT_LIST_VIEW) <= 0)
  153. {
  154. UpdateToCheckGuide(null);
  155. }
  156. else
  157. {
  158. Timers.inst.Remove(CheckGuide);
  159. }
  160. }
  161. protected override void UpdateToCheckGuide(object param)
  162. {
  163. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  164. int index = 0;
  165. for (int i = 0; i < _suitIds.Count; i++)
  166. {
  167. int suitId = _suitIds[i];
  168. bool haveSuit = DressUpMenuSuitDataManager.CheckHaveSuit(suitId);
  169. if (haveSuit == true)
  170. {
  171. index = i;
  172. break;
  173. }
  174. }
  175. GuideController.TryGuide(_ui.m_listSuit, ConstGuideId.SUIT_LIST_VIEW, 3, "选择套装", index);
  176. }
  177. }
  178. }