StoreChargeAddUpView.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. RedDotController.Instance.SetComRedDot(item.m_btnGetGiftBag, !isGet && RoleDataManager.vipLv >= vipCfg.id);
  130. if (item.m_btnGetWeekGiftBag.data == null)
  131. {
  132. item.m_btnGetWeekGiftBag.onClick.Add(OnBtnGetWeekGiftBagClick);
  133. }
  134. item.m_btnGetWeekGiftBag.data = vipCfg.id;
  135. bool isWeekGet = MathHelper.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.VipWeekGetStatus), vipCfg.id);
  136. item.m_btnGetWeekGiftBag.enabled = !isWeekGet;
  137. RedDotController.Instance.SetComRedDot(item.m_btnGetGiftBag, !isWeekGet && RoleDataManager.vipLv >= vipCfg.id);
  138. UI_ListVipItem.ProxyEnd();
  139. }
  140. private void ListRewardItemRender(int index, GObject obj)
  141. {
  142. int[][] rewards = (int[][])obj.parent.data;
  143. if (obj.data == null)
  144. {
  145. obj.data = new ItemView(obj as GComponent);
  146. }
  147. ItemData itemData = ItemUtil.createItemData(rewards[index]);
  148. (obj.data as ItemView).SetData(itemData);
  149. (obj.data as ItemView).ChangeTxtCountStyle();
  150. }
  151. private void OnBtnGetGiftBagClick(EventContext context)
  152. {
  153. GObject obj = context.sender as GObject;
  154. int vipLv = (int)obj.data;
  155. if (RoleDataManager.vipLv < vipLv)
  156. {
  157. PromptController.Instance.ShowFloatTextPrompt("会员等级不足");
  158. return;
  159. }
  160. ShopSProxy.ReqGetVipGiftBag(vipLv).Coroutine();
  161. }
  162. private void OnBtnGetWeekGiftBagClick(EventContext context)
  163. {
  164. GObject obj = context.sender as GObject;
  165. int vipLv = (int)obj.data;
  166. if (RoleDataManager.vipLv < vipLv)
  167. {
  168. PromptController.Instance.ShowFloatTextPrompt("会员等级不足");
  169. return;
  170. }
  171. ShopSProxy.ReqGetVipWeekGiftBag(vipLv).Coroutine();
  172. }
  173. private void OnBtnLeftClick()
  174. {
  175. if (_curSelectIndex == 0) return;
  176. _curSelectIndex = _curSelectIndex - 1;
  177. _ui.m_list.ScrollToView(_curSelectIndex, true);
  178. _ui.m_list.selectedIndex = _curSelectIndex;
  179. }
  180. private void OnBtnRightClick()
  181. {
  182. if (_curSelectIndex == _ui.m_list.numItems - 1) return;
  183. _curSelectIndex = _curSelectIndex + 1;
  184. _ui.m_list.ScrollToView(_curSelectIndex, true);
  185. _ui.m_list.selectedIndex = _curSelectIndex;
  186. }
  187. private void UpdateSuitView()
  188. {
  189. _curSelectIndex = _ui.m_list.GetFirstChildInView();
  190. _ui.m_list.selectedIndex = _curSelectIndex;
  191. }
  192. }
  193. }