SuitGuideView.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. using FairyGUI;
  2. using UI.FieldGuide;
  3. using UI.CommonGame;
  4. using System.Collections.Generic;
  5. using UI.ClothingSynthetic;
  6. namespace GFGGame
  7. {
  8. public class SuitGuideView : BaseWindow
  9. {
  10. private UI_SuitGuideUI _ui;
  11. // private ValueBarController _valueBarController;
  12. private int _menuType = ConstSuitGuideTypeId.TYPE_1;
  13. private int[] _menuTypeDataArray;
  14. private List<int> _suitIds;
  15. private int _suitTypeId;
  16. public override void Dispose()
  17. {
  18. // if (_valueBarController != null)
  19. // {
  20. // _valueBarController.Dispose();
  21. // _valueBarController = null;
  22. // }
  23. if (_ui != null)
  24. {
  25. _ui.Dispose();
  26. _ui = null;
  27. }
  28. base.Dispose();
  29. }
  30. protected override void OnInit()
  31. {
  32. base.OnInit();
  33. packageName = UI_SuitGuideUI.PACKAGE_NAME;
  34. _ui = UI_SuitGuideUI.Create();
  35. this.viewCom = _ui.target;
  36. isfullScreen = true;
  37. // _valueBarController = new ValueBarController(_ui.m_valueBar);
  38. _ui.m_listSuit.itemRenderer = ListSuitItemRenderer;
  39. _ui.m_listType.itemRenderer = ListTypeItemRenderer;
  40. _ui.m_comBoxSort.items = new string[] { "默认排序", "稀有度高", "稀有度低", "收集度高", "收集度低" };
  41. _ui.m_listType.onClickItem.Add(OnClickListTypeItem);
  42. _ui.m_comBoxSort.onChanged.Add(OnComboBoxSortChanged);
  43. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  44. _ui.m_btnSwitch.onClick.Add(OnClickBtnSwitch);
  45. _ui.m_btnHaveGot.onChanged.Add(OnClickBtnHaveGot);
  46. _ui.m_btnNotGet.onChanged.Add(OnClickBtnNotGet);
  47. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("xc_bjbj");
  48. }
  49. protected override void AddEventListener()
  50. {
  51. base.AddEventListener();
  52. EventAgent.AddEventListener(ConstMessage.JUMP_TO_SOURCE, this.Hide);
  53. EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, UpdateSuitStatus);
  54. EventAgent.AddEventListener(ConstMessage.SUIT_BOX_STATUS_CHANGED, OnComboBoxSortChanged);
  55. }
  56. protected override void OnShown()
  57. {
  58. base.OnShown();
  59. // _valueBarController.OnShown();
  60. _ui.m_btnHaveGot.selected = true;
  61. _ui.m_btnNotGet.selected = true;
  62. UpdateListType();
  63. }
  64. protected override void OnHide()
  65. {
  66. base.OnHide();
  67. // _valueBarController.OnHide();
  68. }
  69. protected override void RemoveEventListener()
  70. {
  71. base.RemoveEventListener();
  72. EventAgent.AddEventListener(ConstMessage.JUMP_TO_SOURCE, this.Hide);
  73. EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, UpdateSuitStatus);
  74. EventAgent.RemoveEventListener(ConstMessage.SUIT_BOX_STATUS_CHANGED, OnComboBoxSortChanged);
  75. }
  76. private void OnClickListTypeItem()
  77. {
  78. UpdateListSuit();
  79. }
  80. private void OnComboBoxSortChanged()
  81. {
  82. UpdateListSuit();
  83. }
  84. private void OnClickBtnBack()
  85. {
  86. // this.Hide();
  87. ViewManager.GoBackFrom(ViewName.SUIT_GUIDE_VIEW);
  88. }
  89. private void OnClickBtnSwitch()
  90. {
  91. _menuType = 3 - _menuType;
  92. UpdateListType();
  93. }
  94. private void OnClickBtnHaveGot()
  95. {
  96. if (!_ui.m_btnHaveGot.selected)
  97. {
  98. _ui.m_btnNotGet.selected = true;
  99. }
  100. UpdateListSuit();
  101. }
  102. private void OnClickBtnNotGet()
  103. {
  104. if (!_ui.m_btnNotGet.selected)
  105. {
  106. _ui.m_btnHaveGot.selected = true;
  107. }
  108. UpdateListSuit();
  109. }
  110. private void UpdateSuitBoxStatus(EventContext eventContext)
  111. {
  112. int suitId = (int)eventContext.data;
  113. int num = _ui.m_listSuit.numChildren;
  114. for (int i = 0; i < num; i++)
  115. {
  116. UI_CompSuitItem listItem = UI_CompSuitItem.Proxy(_ui.m_listSuit.GetChildAt(i));
  117. int tempSuitId = (int)listItem.target.data;
  118. if (tempSuitId == suitId)
  119. {
  120. UpdateSuitStatusView(listItem);
  121. }
  122. UI_CompSuitItem.ProxyEnd();
  123. }
  124. }
  125. private void UpdateListType()
  126. {
  127. _ui.m_listType.RemoveChildrenToPool();
  128. switch (_menuType)
  129. {
  130. case ConstSuitGuideTypeId.TYPE_1:
  131. _menuTypeDataArray = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 };
  132. break;
  133. default:
  134. _menuTypeDataArray = new int[] { 8, 9, 10, 11, 12, 13 };
  135. break;
  136. }
  137. _ui.m_listType.numItems = _menuTypeDataArray.Length;
  138. _ui.m_listType.selectedIndex = 0;
  139. UpdateListSuit();
  140. }
  141. private void ListTypeItemRenderer(int index, object item)
  142. {
  143. UI_ButtonSuitType listItem = UI_ButtonSuitType.Proxy(item as GObject);
  144. int typeId = _menuTypeDataArray[index];
  145. SuitGuideMenuCfg cfg = SuitGuideMenuCfgArray.Instance.GetCfg(typeId);
  146. listItem.target.title = cfg.name;
  147. listItem.target.data = typeId;
  148. listItem.m_imgLine.visible = (index != 0);
  149. UI_ButtonSuitType.ProxyEnd();
  150. }
  151. private void UpdateListSuit()
  152. {
  153. _ui.m_listSuit.RemoveChildrenToPool();
  154. UI_ButtonSuitType listItem = UI_ButtonSuitType.Proxy(_ui.m_listType.GetChildAt(_ui.m_listType.selectedIndex));
  155. _suitTypeId = (int)listItem.target.data;
  156. _suitIds = SuitUtil.GetSuitIdList(_ui.m_btnNotGet.selected, _ui.m_btnHaveGot.selected, _suitTypeId, _ui.m_comBoxSort.selectedIndex);
  157. _ui.m_listSuit.numItems = _suitIds.Count;
  158. _ui.m_listSuit.scrollPane.ScrollTop();
  159. UI_ButtonSuitType.ProxyEnd();
  160. }
  161. private void ListSuitItemRenderer(int index, GObject item)
  162. {
  163. UI_CompSuitItem listItem = UI_CompSuitItem.Proxy(item);
  164. int suitId = _suitIds[index];
  165. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
  166. listItem.m_txtName.text = suitCfg.name;
  167. listItem.m_loaderPic.url = ResPathUtil.GetFieldGuideIconPath(suitCfg.res);
  168. RarityIconController.UpdateRarityIcon(listItem.m_rarity, suitId, false, true);
  169. listItem.target.data = suitId;
  170. UpdateSuitStatusView(listItem);
  171. listItem.m_loaderBonusBox.onClick.Clear();
  172. listItem.m_loaderBonusBox.onClick.Add(() =>
  173. {
  174. SuitUtil.ShowSuitGuideBonus(suitId);
  175. });
  176. UI_CompSuitItem.ProxyEnd();
  177. }
  178. private void UpdateSuitStatus(EventContext eventContext)
  179. {
  180. int num = _ui.m_listSuit.numChildren;
  181. for (int i = 0; i < num; i++)
  182. {
  183. UI_CompSuitItem listItem = UI_CompSuitItem.Proxy(_ui.m_listSuit.GetChildAt(i));
  184. UpdateSuitStatusView(listItem);
  185. UI_CompSuitItem.ProxyEnd();
  186. }
  187. }
  188. private void UpdateSuitStatusView(UI_CompSuitItem listItem)
  189. {
  190. int suitId = (int)listItem.target.data;
  191. int count = 0;
  192. int totalCount = 0;
  193. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitId, out count, out totalCount);
  194. listItem.m_progBar.max = totalCount;
  195. listItem.m_progBar.value = count;
  196. bool haveSuit = DressUpMenuSuitDataManager.CheckHaveSuit(suitId);
  197. listItem.m_imgLock.visible = listItem.m_imgLockBg.visible = !haveSuit;
  198. int status = DressUpMenuSuitDataManager.GetSuitGuideBonusStatus(suitId);
  199. RedDotController.Instance.SetComRedDot(listItem.target, status == ConstBonusStatus.CAN_GET, "", -8, 450);
  200. if (status == ConstBonusStatus.CAN_GET)
  201. {
  202. listItem.m_loaderBonusBox.url = "ui://FieldGuide/tujian_lw_1";
  203. }
  204. else
  205. {
  206. listItem.m_loaderBonusBox.url = "ui://FieldGuide/tujian_lw_2";
  207. }
  208. listItem.m_bg.onClick.Clear();
  209. listItem.m_bg.onClick.Add(() =>
  210. {
  211. if (haveSuit)
  212. {
  213. ViewManager.Show(ViewName.SUIT_SHOW_VIEW, new object[] { _suitTypeId, suitId, _suitIds }, new object[] { ViewName.SUIT_GUIDE_VIEW, this.viewData });
  214. }
  215. else
  216. {
  217. ViewManager.Show(ViewName.SUIT_PARTS_DETAIL_VIEW, suitId, new object[] { ViewName.SUIT_GUIDE_VIEW, this.viewData });
  218. }
  219. });
  220. }
  221. }
  222. }