StoreView.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. using UI.Store;
  2. using UI.CommonGame;
  3. using FairyGUI;
  4. using System.Collections.Generic;
  5. using ET;
  6. using UnityEngine;
  7. // using System.Diagnostics;
  8. namespace GFGGame
  9. {
  10. public class StoreView : BaseWindow
  11. {
  12. private UI_StoreUI _ui;
  13. // private ValueBarController _valueBarController;
  14. private List<List<string>> _arenaSubTab = new List<List<string>>();
  15. private int _curTabIndex = 0;
  16. private int _curSubTabIndex = 0;
  17. private string _curViewName = "";
  18. public override void Dispose()
  19. {
  20. if (_ui != null)
  21. {
  22. _ui.Dispose();
  23. }
  24. _arenaSubTab.Clear();
  25. _ui = null;
  26. base.Dispose();
  27. }
  28. protected override void OnInit()
  29. {
  30. base.OnInit();
  31. packageName = UI_StoreUI.PACKAGE_NAME;
  32. _ui = UI_StoreUI.Create();
  33. this.viewCom = _ui.target;
  34. isfullScreen = true;
  35. this.bringToFontOnClick = false;
  36. StoreTabCfg charge = StoreTabCfgArray.Instance.GetCfgByfunctionId(ConstFunctionId.STORE_CHARGE);
  37. Debug.Log("charge[0]" + charge.subTabArr[0][0]);
  38. Debug.Log("charge[0]" + charge.subTabArr[0][1]);
  39. Debug.Log("charge[0]" + charge.subTabArr[0][2]);
  40. Debug.Log("charge[1]" + charge.subTabArr[1][0]);
  41. Debug.Log("charge[1]" + charge.subTabArr[1][1]);
  42. Debug.Log("charge[1]" + charge.subTabArr[1][2]);
  43. StoreTabCfg arenaTab = StoreTabCfgArray.Instance.GetCfgByfunctionId(ConstFunctionId.STORE_ARENA);
  44. _arenaSubTab.Add(new List<string>() { arenaTab.subTabArr[0][0], arenaTab.subTabArr[0][1], arenaTab.subTabArr[0][2] });
  45. for (int i = ArenaDataManager.Instance.SeasonId; i > 0; i--)
  46. {
  47. _arenaSubTab.Add(new List<string>() { string.Format("第{0}赛季", i), i.ToString(), "StoreArenaView" });
  48. }
  49. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("sc_beijing");
  50. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  51. _ui.m_comTab.m_c1.onChanged.Add(OnTabChange);
  52. _ui.m_listSubTab.itemRenderer = RenderListSubTabItem;
  53. _ui.m_listSubTab.onClickItem.Add(OnListSubTabClick);
  54. // _ui.m_listSubTab.selectionController.onChanged.Add(OnListSubTabClick);
  55. }
  56. protected override void AddEventListener()
  57. {
  58. base.AddEventListener();
  59. }
  60. protected override void OnShown()
  61. {
  62. base.OnShown();
  63. //this.viewData[functionId][subTabIndex]
  64. _curTabIndex = this.viewData == null ? ConstStoreTabId.STORE_CHARGE : (int)(this.viewData as object[])[0];
  65. // StoreTabCfg tabCfg = StoreTabCfgArray.Instance.GetCfg(tabIndex);
  66. // _curTabIndex = tabCfg == null ? 1 : tabCfg.index;
  67. _ui.m_comTab.m_c1.selectedIndex = _curTabIndex;
  68. _ui.m_comTab.target.scrollPane.SetPercX((float)(_curTabIndex - 1) / (float)StoreTabCfgArray.Instance.dataArray.Length, false);
  69. _curSubTabIndex = this.viewData == null ? 0 : (int)(this.viewData as object[])[1];
  70. if (_ui.m_listSubTab.numItems > _curSubTabIndex)
  71. {
  72. _ui.m_listSubTab.selectedIndex = _curSubTabIndex;
  73. _ui.m_listSubTab.ScrollToView(_curSubTabIndex);
  74. OnListSubTabChange(_curSubTabIndex);
  75. }
  76. }
  77. protected override void OnHide()
  78. {
  79. base.OnHide();
  80. _ui.m_comTab.m_c1.selectedIndex = 0;
  81. _ui.m_listSubTab.selectedIndex = 0;
  82. }
  83. protected override void RemoveEventListener()
  84. {
  85. base.RemoveEventListener();
  86. }
  87. private void OnClickBtnBack()
  88. {
  89. ViewManager.Hide(_curViewName);
  90. ViewManager.GoBackFrom(typeof(StoreView).FullName, false);
  91. }
  92. private void OnTabChange()
  93. {
  94. StoreTabCfg tabCfg = StoreTabCfgArray.Instance.GetCfg(_ui.m_comTab.m_c1.selectedIndex);
  95. if (tabCfg == null) return;
  96. if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(tabCfg.functionId))
  97. {
  98. _ui.m_comTab.m_c1.selectedIndex = _ui.m_comTab.m_c1.previsousIndex;
  99. }
  100. _curTabIndex = _ui.m_comTab.m_c1.selectedIndex;
  101. if (tabCfg.functionId == ConstFunctionId.STORE_ARENA)
  102. {
  103. _ui.m_listSubTab.numItems = _arenaSubTab.Count;
  104. }
  105. else
  106. {
  107. _ui.m_listSubTab.numItems = tabCfg.subTabArr.Length;
  108. }
  109. _ui.m_listSubTab.selectedIndex = 0;
  110. _curSubTabIndex = 0;
  111. OnListSubTabChange(_curSubTabIndex);
  112. }
  113. private void RenderListSubTabItem(int index, GObject obj)
  114. {
  115. GButton item = obj.asButton;
  116. StoreTabCfg tabCfg = StoreTabCfgArray.Instance.GetCfg(_curTabIndex);
  117. int menu2 = 0;
  118. if (tabCfg.functionId == ConstFunctionId.STORE_ARENA)
  119. {
  120. item.title = _arenaSubTab[index][0];
  121. menu2 = int.Parse(_arenaSubTab[index][1]);
  122. }
  123. else
  124. {
  125. item.title = tabCfg.subTabArr[index][0];
  126. menu2 = int.Parse(tabCfg.subTabArr[index][1]);
  127. }
  128. item.data = index;
  129. if (menu2 == ConstStoreSubId.STORE_CHARGE_ADDUP)
  130. {
  131. RedDotController.Instance.SetComRedDot(_ui.m_comTab.m_btn0.target, RedDotDataManager.Instance.GetChargeAddUpReward());
  132. }
  133. }
  134. private void OnListSubTabClick(EventContext context)
  135. {
  136. GObject obj = context.data as GObject;
  137. int index = (int)obj.data;
  138. if (index < 0) return;
  139. OnListSubTabChange(index);
  140. }
  141. private void OnListSubTabChange(int index)
  142. {
  143. StoreTabCfg tabCfg = StoreTabCfgArray.Instance.GetCfg(_curTabIndex);
  144. string viewName = "";
  145. int menu2 = 0;
  146. if (tabCfg.functionId == ConstFunctionId.STORE_ARENA)
  147. {
  148. menu2 = int.Parse(_arenaSubTab[index][1]);
  149. viewName = _arenaSubTab[index][2];
  150. }
  151. else
  152. {
  153. menu2 = int.Parse(tabCfg.subTabArr[index][1]);
  154. viewName = tabCfg.subTabArr[index][2];
  155. }
  156. if (!FunctionOpenDataManager.Instance.CheckIsFunOpenById(viewName))
  157. {
  158. _ui.m_listSubTab.selectedIndex = _curSubTabIndex;
  159. return;
  160. }
  161. ViewManager.Hide(_curViewName);
  162. if (!string.IsNullOrEmpty(viewName) && viewName != "“”")
  163. {
  164. ViewManager.Show("GFGGame." + viewName, menu2);
  165. }
  166. _curSubTabIndex = index;
  167. _curViewName = "GFGGame." + viewName;
  168. }
  169. private void UpdateRedDot()
  170. {
  171. RedDotController.Instance.SetComRedDot(_ui.m_comTab.m_btn0.target, RedDotDataManager.Instance.GetChargeAddUpReward());
  172. }
  173. }
  174. }