StoreChargeAddUpView.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. using UI.Store;
  2. using UI.CommonGame;
  3. using FairyGUI;
  4. using System.Collections.Generic;
  5. using ET;
  6. using System;
  7. namespace GFGGame
  8. {
  9. public class StoreChargeAddUpView : BaseWindow
  10. {
  11. private UI_StoreChargeAddUpUI _ui;
  12. private ValueBarController _valueBarController;
  13. private List<ShopCfg> _shopCfgs;
  14. private DressUpObjUI _dressUpObjUI;
  15. private List<DressUpObjUI> _dressUpObjUIs = new List<DressUpObjUI>();
  16. private int _curSelectIndex = 0;
  17. public override void Dispose()
  18. {
  19. if (_valueBarController != null)
  20. {
  21. _valueBarController.Dispose();
  22. _valueBarController = null;
  23. }
  24. if (_dressUpObjUI != null)
  25. {
  26. _dressUpObjUI.Dispose();
  27. _dressUpObjUI = null;
  28. }
  29. for (int i = 0; i < _dressUpObjUIs.Count; i++)
  30. {
  31. if (_dressUpObjUIs[i] != null)
  32. {
  33. _dressUpObjUIs[i].Dispose();
  34. _dressUpObjUIs[i] = null;
  35. }
  36. }
  37. if (_ui != null)
  38. {
  39. _ui.Dispose();
  40. }
  41. _ui = null;
  42. base.Dispose();
  43. }
  44. protected override void OnInit()
  45. {
  46. base.OnInit();
  47. packageName = UI_StoreChargeAddUpUI.PACKAGE_NAME;
  48. _ui = UI_StoreChargeAddUpUI.Create();
  49. this.viewCom = _ui.target;
  50. isfullScreen = true;
  51. this.clickBlankToClose = false;
  52. _dressUpObjUI = new DressUpObjUI("SceneSuitFoster");
  53. _valueBarController = new ValueBarController(_ui.m_valueBar);
  54. _ui.m_list.itemRenderer = ListItemRenderer;
  55. _ui.m_list.SetVirtual();
  56. _ui.m_list.scrollPane.onScrollEnd.Add(UpdateSuitView);
  57. _ui.m_list.scrollPane.decelerationRate = 0.8f;
  58. _ui.m_btnLeft.onClick.Add(OnBtnLeftClick);
  59. _ui.m_btnRight.onClick.Add(OnBtnRightClick);
  60. }
  61. protected override void AddEventListener()
  62. {
  63. base.AddEventListener();
  64. EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, RefreshList);
  65. }
  66. protected override void OnShown()
  67. {
  68. base.OnShown();
  69. _valueBarController.OnShown();
  70. RefreshList();
  71. _curSelectIndex = Math.Max(0, RoleDataManager.vipLv - 1);
  72. _ui.m_list.selectedIndex = _curSelectIndex;
  73. _ui.m_list.ScrollToView(_curSelectIndex);
  74. ShopViewManager.Instance.UpdateVipProgressCom(_ui.m_comVipLv.target);
  75. }
  76. protected override void OnHide()
  77. {
  78. base.OnHide();
  79. _valueBarController.OnHide();
  80. }
  81. protected override void RemoveEventListener()
  82. {
  83. base.RemoveEventListener();
  84. EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, RefreshList);
  85. }
  86. private void RefreshList()
  87. {
  88. _ui.m_list.numItems = VipCfgArray.Instance.dataArray.Length - 1;
  89. }
  90. private void ListItemRenderer(int index, GObject obj)
  91. {
  92. VipCfg lastVipCfg = VipCfgArray.Instance.dataArray[index];
  93. VipCfg vipCfg = VipCfgArray.Instance.dataArray[index + 1];
  94. UI_ListVipItem item = UI_ListVipItem.Proxy(obj);
  95. string name = SuitCfgArray.Instance.GetCfg(vipCfg.suitId).name;
  96. item.m_txtName0.text = name.Length > 0 ? name.Substring(0, 1) : "";
  97. item.m_txtName1.text = name.Length > 1 ? name.Substring(1, 1) : "";
  98. item.m_txtName2.text = name.Length > 2 ? name.Substring(2, 1) : "";
  99. item.m_txtName3.text = name.Length > 3 ? name.Substring(3, 1) : "";
  100. item.m_txtName4.text = name.Length > 4 ? name.Substring(4) : "";
  101. item.m_txtGiftBag.SetVar("value", vipCfg.id.ToString()).FlushVars();
  102. if (item.m_listGiftBag.data == null)
  103. {
  104. item.m_listGiftBag.itemRenderer = ListRewardItemRender;
  105. }
  106. item.m_listGiftBag.data = lastVipCfg.bonusOnceArr;
  107. item.m_listGiftBag.numItems = lastVipCfg.bonusOnceArr.Length;
  108. item.m_txtWeekGiftBag.SetVar("value", vipCfg.id.ToString()).FlushVars();
  109. if (item.m_listWeekGiftBag.data == null)
  110. {
  111. item.m_listWeekGiftBag.itemRenderer = ListRewardItemRender;
  112. }
  113. item.m_listWeekGiftBag.data = vipCfg.bonusWeekArr;
  114. item.m_listWeekGiftBag.numItems = vipCfg.bonusWeekArr.Length;
  115. if (item.m_holder.data == null)
  116. {
  117. DressUpObjUI dressUpObjUI = new DressUpObjUI("SceneSuitFoster");
  118. item.m_holder.data = dressUpObjUI;
  119. _dressUpObjUIs.Add(dressUpObjUI);
  120. }
  121. _dressUpObjUI = item.m_holder.data as DressUpObjUI;
  122. _dressUpObjUI.ResetSceneObj(85, false, true, null, false);
  123. _dressUpObjUI.dressUpObj.PutOnSuitCfg(vipCfg.suitId, true, new int[] { ConstDressUpItemType.BEI_JING }, true, false);
  124. _dressUpObjUI.UpdateWrapper(item.m_holder);
  125. if (item.m_btnShow.data == null)
  126. {
  127. item.m_btnShow.onClick.Add(OnBtnShowClick);
  128. }
  129. item.m_btnShow.data = vipCfg.suitId;
  130. if (item.m_btnGetGiftBag.data == null)
  131. {
  132. item.m_btnGetGiftBag.onClick.Add(OnBtnGetGiftBagClick);
  133. }
  134. item.m_btnGetGiftBag.data = vipCfg.id;
  135. bool isGet = MathHelper.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.VipGetStatus), vipCfg.id);
  136. item.m_btnGetGiftBag.enabled = !isGet;
  137. RedDotController.Instance.SetComRedDot(item.m_btnGetGiftBag, !isGet && RoleDataManager.vipLv >= vipCfg.id);
  138. if (item.m_btnGetWeekGiftBag.data == null)
  139. {
  140. item.m_btnGetWeekGiftBag.onClick.Add(OnBtnGetWeekGiftBagClick);
  141. }
  142. item.m_btnGetWeekGiftBag.data = vipCfg.id;
  143. bool isWeekGet = MathHelper.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.VipWeekGetStatus), vipCfg.id);
  144. item.m_btnGetWeekGiftBag.enabled = !isWeekGet;
  145. RedDotController.Instance.SetComRedDot(item.m_btnGetWeekGiftBag, !isWeekGet && RoleDataManager.vipLv >= vipCfg.id);
  146. UI_ListVipItem.ProxyEnd();
  147. }
  148. private void ListRewardItemRender(int index, GObject obj)
  149. {
  150. int[][] rewards = (int[][])obj.parent.data;
  151. if (obj.data == null)
  152. {
  153. obj.data = new ItemView(obj as GComponent);
  154. }
  155. ItemData itemData = ItemUtil.createItemData(rewards[index]);
  156. (obj.data as ItemView).SetData(itemData);
  157. (obj.data as ItemView).ChangeTxtCountStyle();
  158. }
  159. private void OnBtnShowClick(EventContext context)
  160. {
  161. GObject obj = context.sender as GObject;
  162. int suitId = (int)obj.data;
  163. int _suitTypeId = 0;
  164. for (int i = 0; i < SuitGuideMenuCfgArray.Instance.dataArray.Length; i++)
  165. {
  166. string[] suitIds = SuitGuideMenuCfgArray.Instance.dataArray[i].suitIds.Split(';');
  167. if (Array.IndexOf(suitIds, suitId.ToString()) >= 0)
  168. {
  169. _suitTypeId = SuitGuideMenuCfgArray.Instance.dataArray[i].id;
  170. break;
  171. }
  172. }
  173. ViewManager.Show<SuitShowView>(new object[] { _suitTypeId, suitId, new List<int>() { suitId }, false });
  174. }
  175. private void OnBtnGetGiftBagClick(EventContext context)
  176. {
  177. GObject obj = context.sender as GObject;
  178. int vipLv = (int)obj.data;
  179. if (RoleDataManager.vipLv < vipLv)
  180. {
  181. PromptController.Instance.ShowFloatTextPrompt("会员等级不足");
  182. return;
  183. }
  184. ShopSProxy.ReqGetVipGiftBag(vipLv).Coroutine();
  185. }
  186. private void OnBtnGetWeekGiftBagClick(EventContext context)
  187. {
  188. GObject obj = context.sender as GObject;
  189. int vipLv = (int)obj.data;
  190. if (RoleDataManager.vipLv < vipLv)
  191. {
  192. PromptController.Instance.ShowFloatTextPrompt("会员等级不足");
  193. return;
  194. }
  195. ShopSProxy.ReqGetVipWeekGiftBag(vipLv).Coroutine();
  196. }
  197. private void OnBtnLeftClick()
  198. {
  199. if (_curSelectIndex == 0) return;
  200. _curSelectIndex = _curSelectIndex - 1;
  201. _ui.m_list.ScrollToView(_curSelectIndex, true);
  202. // _ui.m_list.selectedIndex = _curSelectIndex;
  203. }
  204. private void OnBtnRightClick()
  205. {
  206. if (_curSelectIndex == _ui.m_list.numItems - 1) return;
  207. _curSelectIndex = _curSelectIndex + 1;
  208. _ui.m_list.ScrollToView(_curSelectIndex, true);
  209. // _ui.m_list.selectedIndex = _curSelectIndex;
  210. }
  211. private void UpdateSuitView()
  212. {
  213. _curSelectIndex = _ui.m_list.GetFirstChildInView();
  214. _ui.m_list.selectedIndex = _curSelectIndex;
  215. }
  216. }
  217. }