StoreChargeAddUpView.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. }
  65. protected override void OnShown()
  66. {
  67. base.OnShown();
  68. _valueBarController.OnShown();
  69. _ui.m_list.numItems = VipCfgArray.Instance.dataArray.Length - 1;
  70. _curSelectIndex = Math.Max(0, RoleDataManager.vipLv - 1);
  71. _ui.m_list.selectedIndex = _curSelectIndex;
  72. _ui.m_list.ScrollToView(_curSelectIndex);
  73. ShopViewManager.Instance.UpdateVipProgressCom(_ui.m_comVipLv.target);
  74. }
  75. protected override void OnHide()
  76. {
  77. base.OnHide();
  78. _valueBarController.OnHide();
  79. }
  80. protected override void RemoveEventListener()
  81. {
  82. base.RemoveEventListener();
  83. }
  84. private void RefreshList()
  85. {
  86. }
  87. private void ListItemRenderer(int index, GObject obj)
  88. {
  89. VipCfg lastVipCfg = VipCfgArray.Instance.dataArray[index];
  90. VipCfg vipCfg = VipCfgArray.Instance.dataArray[index + 1];
  91. UI_ListVipItem item = UI_ListVipItem.Proxy(obj);
  92. string name = SuitCfgArray.Instance.GetCfg(vipCfg.suitId).name;
  93. item.m_txtName0.text = name.Length > 0 ? name.Substring(0, 1) : "";
  94. item.m_txtName1.text = name.Length > 1 ? name.Substring(1, 1) : "";
  95. item.m_txtName2.text = name.Length > 2 ? name.Substring(2, 1) : "";
  96. item.m_txtName3.text = name.Length > 3 ? name.Substring(3, 1) : "";
  97. item.m_txtName4.text = name.Length > 4 ? name.Substring(4) : "";
  98. item.m_txtGiftBag.SetVar("value", vipCfg.id.ToString()).FlushVars();
  99. if (item.m_listGiftBag.data == null)
  100. {
  101. item.m_listGiftBag.itemRenderer = ListRewardItemRender;
  102. }
  103. item.m_listGiftBag.data = lastVipCfg.bonusOnceArr;
  104. item.m_listGiftBag.numItems = lastVipCfg.bonusOnceArr.Length;
  105. item.m_txtWeekGiftBag.SetVar("value", vipCfg.id.ToString()).FlushVars();
  106. if (item.m_listWeekGiftBag.data == null)
  107. {
  108. item.m_listWeekGiftBag.itemRenderer = ListRewardItemRender;
  109. }
  110. item.m_listWeekGiftBag.data = vipCfg.bonusWeekArr;
  111. item.m_listWeekGiftBag.numItems = vipCfg.bonusWeekArr.Length;
  112. if (item.m_holder.data == null)
  113. {
  114. DressUpObjUI dressUpObjUI = new DressUpObjUI("SceneSuitFoster");
  115. item.m_holder.data = dressUpObjUI;
  116. _dressUpObjUIs.Add(dressUpObjUI);
  117. }
  118. _dressUpObjUI = item.m_holder.data as DressUpObjUI;
  119. _dressUpObjUI.ResetSceneObj(90, false, true, null, false);
  120. _dressUpObjUI.dressUpObj.PutOnSuitCfg(vipCfg.suitId, true, new int[] { ConstDressUpItemType.BEI_JING }, true, false);
  121. _dressUpObjUI.UpdateWrapper(item.m_holder);
  122. if (item.m_btnGetGiftBag.data == null)
  123. {
  124. item.m_btnGetGiftBag.onClick.Add(OnBtnGetGiftBagClick);
  125. }
  126. item.m_btnGetGiftBag.data = vipCfg.id;
  127. bool isGet = MathHelper.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.VipGetStatus), vipCfg.id);
  128. item.m_btnGetGiftBag.enabled = !isGet;
  129. if (item.m_btnGetWeekGiftBag.data == null)
  130. {
  131. item.m_btnGetWeekGiftBag.onClick.Add(OnBtnGetWeekGiftBagClick);
  132. }
  133. item.m_btnGetWeekGiftBag.data = vipCfg.id;
  134. bool isWeekGet = MathHelper.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.VipWeekGetStatus), vipCfg.id);
  135. item.m_btnGetWeekGiftBag.enabled = !isWeekGet;
  136. UI_ListVipItem.ProxyEnd();
  137. }
  138. private void ListRewardItemRender(int index, GObject obj)
  139. {
  140. int[][] rewards = (int[][])obj.parent.data;
  141. if (obj.data == null)
  142. {
  143. obj.data = new ItemView(obj as GComponent);
  144. }
  145. ItemData itemData = ItemUtil.createItemData(rewards[index]);
  146. (obj.data as ItemView).SetData(itemData);
  147. (obj.data as ItemView).ChangeTxtCountStyle();
  148. }
  149. private void OnBtnGetGiftBagClick(EventContext context)
  150. {
  151. GObject obj = context.sender as GObject;
  152. int vipLv = (int)obj.data;
  153. if (RoleDataManager.vipLv < vipLv)
  154. {
  155. PromptController.Instance.ShowFloatTextPrompt("会员等级不足");
  156. return;
  157. }
  158. ShopSProxy.ReqGetVipGiftBag(vipLv).Coroutine();
  159. }
  160. private void OnBtnGetWeekGiftBagClick(EventContext context)
  161. {
  162. GObject obj = context.sender as GObject;
  163. int vipLv = (int)obj.data;
  164. if (RoleDataManager.vipLv < vipLv)
  165. {
  166. PromptController.Instance.ShowFloatTextPrompt("会员等级不足");
  167. return;
  168. }
  169. ShopSProxy.ReqGetVipWeekGiftBag(vipLv).Coroutine();
  170. }
  171. private void OnBtnLeftClick()
  172. {
  173. if (_curSelectIndex == 0) return;
  174. _curSelectIndex = _curSelectIndex - 1;
  175. _ui.m_list.ScrollToView(_curSelectIndex, true);
  176. _ui.m_list.selectedIndex = _curSelectIndex;
  177. }
  178. private void OnBtnRightClick()
  179. {
  180. if (_curSelectIndex == _ui.m_list.numItems - 1) return;
  181. _curSelectIndex = _curSelectIndex + 1;
  182. _ui.m_list.ScrollToView(_curSelectIndex, true);
  183. _ui.m_list.selectedIndex = _curSelectIndex;
  184. }
  185. private void UpdateSuitView()
  186. {
  187. _curSelectIndex = _ui.m_list.GetFirstChildInView();
  188. _ui.m_list.selectedIndex = _curSelectIndex;
  189. }
  190. }
  191. }