StoreChargeAddUpView.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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(85, 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_btnShow.data == null)
  123. {
  124. item.m_btnShow.onClick.Add(OnBtnShowClick);
  125. }
  126. item.m_btnShow.data = vipCfg.suitId;
  127. if (item.m_btnGetGiftBag.data == null)
  128. {
  129. item.m_btnGetGiftBag.onClick.Add(OnBtnGetGiftBagClick);
  130. }
  131. item.m_btnGetGiftBag.data = vipCfg.id;
  132. bool isGet = MathHelper.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.VipGetStatus), vipCfg.id);
  133. item.m_btnGetGiftBag.enabled = !isGet;
  134. RedDotController.Instance.SetComRedDot(item.m_btnGetGiftBag, !isGet && RoleDataManager.vipLv >= vipCfg.id);
  135. if (item.m_btnGetWeekGiftBag.data == null)
  136. {
  137. item.m_btnGetWeekGiftBag.onClick.Add(OnBtnGetWeekGiftBagClick);
  138. }
  139. item.m_btnGetWeekGiftBag.data = vipCfg.id;
  140. bool isWeekGet = MathHelper.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.VipWeekGetStatus), vipCfg.id);
  141. item.m_btnGetWeekGiftBag.enabled = !isWeekGet;
  142. RedDotController.Instance.SetComRedDot(item.m_btnGetGiftBag, !isWeekGet && RoleDataManager.vipLv >= vipCfg.id);
  143. UI_ListVipItem.ProxyEnd();
  144. }
  145. private void ListRewardItemRender(int index, GObject obj)
  146. {
  147. int[][] rewards = (int[][])obj.parent.data;
  148. if (obj.data == null)
  149. {
  150. obj.data = new ItemView(obj as GComponent);
  151. }
  152. ItemData itemData = ItemUtil.createItemData(rewards[index]);
  153. (obj.data as ItemView).SetData(itemData);
  154. (obj.data as ItemView).ChangeTxtCountStyle();
  155. }
  156. private void OnBtnShowClick(EventContext context)
  157. {
  158. GObject obj = context.sender as GObject;
  159. int suitId = (int)obj.data;
  160. int _suitTypeId = 0;
  161. for (int i = 0; i < SuitGuideMenuCfgArray.Instance.dataArray.Length; i++)
  162. {
  163. string[] suitIds = SuitGuideMenuCfgArray.Instance.dataArray[i].suitIds.Split(';');
  164. if (Array.IndexOf(suitIds, suitId.ToString()) >= 0)
  165. {
  166. _suitTypeId = SuitGuideMenuCfgArray.Instance.dataArray[i].id;
  167. break;
  168. }
  169. }
  170. ViewManager.Show<SuitShowView>(new object[] { _suitTypeId, suitId, new List<int>() { suitId } });
  171. }
  172. private void OnBtnGetGiftBagClick(EventContext context)
  173. {
  174. GObject obj = context.sender as GObject;
  175. int vipLv = (int)obj.data;
  176. if (RoleDataManager.vipLv < vipLv)
  177. {
  178. PromptController.Instance.ShowFloatTextPrompt("会员等级不足");
  179. return;
  180. }
  181. ShopSProxy.ReqGetVipGiftBag(vipLv).Coroutine();
  182. }
  183. private void OnBtnGetWeekGiftBagClick(EventContext context)
  184. {
  185. GObject obj = context.sender as GObject;
  186. int vipLv = (int)obj.data;
  187. if (RoleDataManager.vipLv < vipLv)
  188. {
  189. PromptController.Instance.ShowFloatTextPrompt("会员等级不足");
  190. return;
  191. }
  192. ShopSProxy.ReqGetVipWeekGiftBag(vipLv).Coroutine();
  193. }
  194. private void OnBtnLeftClick()
  195. {
  196. if (_curSelectIndex == 0) return;
  197. _curSelectIndex = _curSelectIndex - 1;
  198. _ui.m_list.ScrollToView(_curSelectIndex, true);
  199. // _ui.m_list.selectedIndex = _curSelectIndex;
  200. }
  201. private void OnBtnRightClick()
  202. {
  203. if (_curSelectIndex == _ui.m_list.numItems - 1) return;
  204. _curSelectIndex = _curSelectIndex + 1;
  205. _ui.m_list.ScrollToView(_curSelectIndex, true);
  206. // _ui.m_list.selectedIndex = _curSelectIndex;
  207. }
  208. private void UpdateSuitView()
  209. {
  210. _curSelectIndex = _ui.m_list.GetFirstChildInView();
  211. _ui.m_list.selectedIndex = _curSelectIndex;
  212. }
  213. }
  214. }