NewLimitChargeView.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. using UI.Store;
  2. using UI.CommonGame;
  3. using FairyGUI;
  4. using System.Collections.Generic;
  5. using ET;
  6. using System;
  7. using Hutool;
  8. using UI.DailyWelfare;
  9. namespace GFGGame
  10. {
  11. public class NewLimitChargeView : BaseWindow
  12. {
  13. private UI_StoreChargeAddUpUI _ui;
  14. private List<ShopCfg> _shopCfgs;
  15. private DressUpObjUI _dressUpObjUI;
  16. private List<DressUpObjUI> _dressUpObjUIs = new List<DressUpObjUI>();
  17. private int _curSelectIndex = 0;
  18. private int _activityId = 0;
  19. private ActivityInfo _activityInfo;
  20. private List<ActivityRechargeCfg> _rechargeCfgs;
  21. public override void Dispose()
  22. {
  23. if (_dressUpObjUI != null)
  24. {
  25. _dressUpObjUI.Dispose();
  26. _dressUpObjUI = null;
  27. }
  28. for (int i = 0; i < _dressUpObjUIs.Count; i++)
  29. {
  30. if (_dressUpObjUIs[i] != null)
  31. {
  32. _dressUpObjUIs[i].Dispose();
  33. _dressUpObjUIs[i] = null;
  34. }
  35. }
  36. if (_ui != null)
  37. {
  38. _ui.Dispose();
  39. }
  40. _ui = null;
  41. base.Dispose();
  42. }
  43. protected override void OnInit()
  44. {
  45. base.OnInit();
  46. packageName = UI_StoreChargeAddUpUI.PACKAGE_NAME;
  47. _ui = UI_StoreChargeAddUpUI.Create();
  48. this.viewCom = _ui.target;
  49. isfullScreen = true;
  50. this.clickBlankToClose = false;
  51. this.bringToFontOnClick = false;
  52. _dressUpObjUI = new DressUpObjUI("SceneSuitFoster");
  53. _ui.m_list.itemRenderer = ListItemRenderer;
  54. _ui.m_list.SetVirtual();
  55. _ui.m_list.scrollPane.onScrollEnd.Add(UpdateSuitView);
  56. _ui.m_list.scrollPane.decelerationRate = 0.8f;
  57. _ui.m_btnLeft.onClick.Add(OnBtnLeftClick);
  58. _ui.m_btnRight.onClick.Add(OnBtnRightClick);
  59. }
  60. protected override void AddEventListener()
  61. {
  62. base.AddEventListener();
  63. EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, RefreshList);
  64. EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateRedDot);
  65. }
  66. protected override void OnShown()
  67. {
  68. base.OnShown();
  69. RefreshList();
  70. _curSelectIndex = Math.Max(0, RoleDataManager.vipLv - 1);
  71. _ui.m_list.selectedIndex = _curSelectIndex;
  72. _ui.m_list.ScrollToView(_curSelectIndex);
  73. _ui.m_btnLeft.visible = _curSelectIndex == 0 ? false : true;
  74. _ui.m_btnRight.visible = _curSelectIndex < _ui.m_list.numItems - 1 ? true : false;
  75. _activityId = (int)(this.viewData as object[])[0];
  76. _rechargeCfgs = ActivityRechargeCfgArray.Instance.GetCfgsByactivityId(_activityId);
  77. UpdateRedDot();
  78. }
  79. protected override void OnHide()
  80. {
  81. base.OnHide();
  82. }
  83. protected override void RemoveEventListener()
  84. {
  85. base.RemoveEventListener();
  86. EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, RefreshList);
  87. EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateRedDot);
  88. }
  89. private void RefreshList()
  90. {
  91. _ui.m_list.numItems = VipCfgArray.Instance.dataArray.Length - 1;
  92. }
  93. private void ListItemRenderer(int index, GObject obj)
  94. {
  95. VipCfg lastVipCfg = VipCfgArray.Instance.dataArray[index];
  96. VipCfg vipCfg = VipCfgArray.Instance.dataArray[index + 1];
  97. UI_ListShowItem item = UI_ListShowItem.Proxy(obj);
  98. string name = SuitCfgArray.Instance.GetCfg(vipCfg.suitId).name;
  99. item.m_txtName0.text = name.Length > 0 ? name.Substring(0, 1) : "";
  100. item.m_txtName1.text = name.Length > 1 ? name.Substring(1, 1) : "";
  101. item.m_txtName2.text = name.Length > 2 ? name.Substring(2, 1) : "";
  102. item.m_txtName3.text = name.Length > 3 ? name.Substring(3, 1) : "";
  103. item.m_txtName4.text = name.Length > 4 ? name.Substring(4) : "";
  104. item.m_txtGiftBag.SetVar("value", vipCfg.id.ToString()).FlushVars();
  105. if (item.m_listGiftBag.data == null)
  106. {
  107. item.m_listGiftBag.itemRenderer = ListRewardItemRender;
  108. item.m_listGiftBag.onClickItem.Add(OnListItemClick);
  109. }
  110. item.m_listGiftBag.data = lastVipCfg.bonusOnceArr;
  111. item.m_listGiftBag.numItems = lastVipCfg.bonusOnceArr.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(80, false, true, null, false);
  120. _dressUpObjUI.dressUpObj.PutOnSuitCfg(vipCfg.suitId, true, new int[] { ConstDressUpItemType.BEI_JING }, false, 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 = MathUtil.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.VipGetStatus), vipCfg.id);
  133. item.m_btnGetGiftBag.grayed = isGet || vipCfg.id > RoleDataManager.vipLv;
  134. RedDotController.Instance.SetComRedDot(item.m_btnGetGiftBag, !isGet && RoleDataManager.vipLv >= vipCfg.id);
  135. bool canGet = GameGlobal.myNumericComponent.GetAsInt(NumericType.VipWeekGetStatus) == 0 && RoleDataManager.vipLv == vipCfg.id;
  136. UI_ListVipItem.ProxyEnd();
  137. }
  138. private void ListRewardItemRender(int index, GObject obj)
  139. {
  140. int[][] rewards = (int[][])obj.parent.data;
  141. UI_ComItem item = UI_ComItem.Proxy(obj);
  142. ItemData itemData = ItemUtil.createItemData(rewards[index]);
  143. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
  144. item.m_txtCount.text = itemData.num.ToString();
  145. item.target.data = itemCfg;
  146. item.m_QualityType.selectedIndex = itemData.rarity - 1;
  147. item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  148. UI_ComItem.ProxyEnd();
  149. }
  150. private void OnBtnShowClick(EventContext context)
  151. {
  152. GObject obj = context.sender as GObject;
  153. int suitId = (int)obj.data;
  154. int _suitTypeId = 0;
  155. for (int i = 0; i < SuitGuideMenuCfgArray.Instance.dataArray.Length; i++)
  156. {
  157. string[] suitIds = SuitGuideMenuCfgArray.Instance.dataArray[i].suitIds.Split(';');
  158. if (Array.IndexOf(suitIds, suitId.ToString()) >= 0)
  159. {
  160. _suitTypeId = SuitGuideMenuCfgArray.Instance.dataArray[i].id;
  161. break;
  162. }
  163. }
  164. ViewManager.Show<SuitShowView>(new object[] { _suitTypeId, suitId, new List<int>() { suitId }, false });
  165. }
  166. private void OnBtnWeekClick(EventContext context)
  167. {
  168. GObject obj = context.sender as GObject;
  169. int vipLv = (int)obj.data;
  170. ViewManager.Show<WeekGiftView>(vipLv);
  171. }
  172. private void OnBtnGetGiftBagClick(EventContext context)
  173. {
  174. GObject obj = context.sender as GObject;
  175. int vipLv = (int)obj.data;
  176. bool isGet = MathUtil.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.VipGetStatus), vipLv);
  177. if (isGet)
  178. {
  179. PromptController.Instance.ShowFloatTextPrompt("会员等级礼包已领取");
  180. return;
  181. }
  182. if (RoleDataManager.vipLv < vipLv)
  183. {
  184. PromptController.Instance.ShowFloatTextPrompt("会员等级不足");
  185. return;
  186. }
  187. ShopSProxy.ReqGetVipGiftBag(vipLv).Coroutine();
  188. }
  189. private void OnBtnLeftClick()
  190. {
  191. if (_curSelectIndex == 0) return;
  192. _curSelectIndex = _curSelectIndex - 1;
  193. _ui.m_list.ScrollToView(_curSelectIndex, true);
  194. UpdateRedDot();
  195. }
  196. private void OnBtnRightClick()
  197. {
  198. if (_curSelectIndex == _ui.m_list.numItems - 1) return;
  199. _curSelectIndex = _curSelectIndex + 1;
  200. _ui.m_list.ScrollToView(_curSelectIndex, true);
  201. UpdateRedDot();
  202. }
  203. private void UpdateSuitView()
  204. {
  205. _curSelectIndex = _ui.m_list.GetFirstChildInView();
  206. _ui.m_list.selectedIndex = _curSelectIndex;
  207. _ui.m_btnLeft.visible = _curSelectIndex == 0 ? false : true;
  208. _ui.m_btnRight.visible = _curSelectIndex < _ui.m_list.numItems - 1 ? true : false;
  209. }
  210. private void UpdateRedDot()
  211. {
  212. bool leftRed = false;
  213. bool rightRed = false;
  214. VipCfg[] vipCfgs = VipCfgArray.Instance.dataArray;
  215. for (int i = 1; i < vipCfgs.Length; i++)
  216. {
  217. bool isGet = MathUtil.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.VipGetStatus), vipCfgs[i].id);
  218. bool red = !isGet && RoleDataManager.vipLv >= vipCfgs[i].id;
  219. if (red && _curSelectIndex > i - 1)
  220. {
  221. leftRed = true;
  222. break;
  223. }
  224. if (red && _curSelectIndex + 1 < i)
  225. {
  226. rightRed = true;
  227. break;
  228. }
  229. }
  230. if (GameGlobal.myNumericComponent.GetAsInt(NumericType.VipWeekGetStatus) == 0 && RoleDataManager.vipLv > 0 && _curSelectIndex > RoleDataManager.vipLv - 1) { leftRed = true; }
  231. if (GameGlobal.myNumericComponent.GetAsInt(NumericType.VipWeekGetStatus) == 0 && RoleDataManager.vipLv > 0 && _curSelectIndex + 1 < RoleDataManager.vipLv) { rightRed = true; }
  232. RedDotController.Instance.SetComRedDot(_ui.m_btnLeft, leftRed);
  233. RedDotController.Instance.SetComRedDot(_ui.m_btnRight, rightRed);
  234. }
  235. private void OnListItemClick(EventContext context)
  236. {
  237. GComponent comItem = (context.data as GComponent);
  238. ItemCfg itemCfg = comItem.data as ItemCfg;
  239. GoodsItemTipsController.ShowItemTips(itemCfg.id);
  240. }
  241. }
  242. }