NewLimitChargeView.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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_NewLimitChargeUI _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_LimitChargeUI.PACKAGE_NAME;
  47. _ui = UI_NewLimitChargeUI.Create();
  48. this.viewCom = _ui.target;
  49. isfullScreen = true;
  50. isReturnView = true;
  51. this.clickBlankToClose = false;
  52. this.bringToFontOnClick = false;
  53. _dressUpObjUI = new DressUpObjUI("SceneSuitFoster");
  54. _ui.m_btnLeft.onClick.Add(OnBtnLeftClick);
  55. _ui.m_btnRight.onClick.Add(OnBtnRightClick);
  56. _ui.m_btnBack.onClick.Add(OnBtnBackClick);
  57. _ui.m_btnCharge.onClick.Add(OnBtnChargeClick);
  58. }
  59. protected override void AddEventListener()
  60. {
  61. base.AddEventListener();
  62. EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, RefreshList);
  63. //EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateRedDot);
  64. }
  65. protected override void OnShown()
  66. {
  67. base.OnShown();
  68. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("bg_fhl");
  69. _activityId = (int)(this.viewData as object[])[0];
  70. _rechargeCfgs = ActivityRechargeCfgArray.Instance.GetCfgsByactivityId(_activityId);
  71. _activityInfo = ActivityGlobalDataManager.Instance.GetActivityInfo(_activityId);
  72. //UpdateRedDot();
  73. RefreshList();
  74. string name = SuitCfgArray.Instance.GetCfg(_rechargeCfgs[0].suitId).name;
  75. _ui.m_packageName.text = name;
  76. _ui.m_btnLeft.visible = _curSelectIndex == 0 ? false : true;
  77. _ui.m_btnRight.visible = _curSelectIndex < _rechargeCfgs.Count - 1 ? true : false;
  78. _ui.m_packageName.text = SuitCfgArray.Instance.GetCfg(_rechargeCfgs[_curSelectIndex].suitId).name;
  79. ItemRenderer(_curSelectIndex);
  80. Timers.inst.Add(1, 0, UpdateTime);
  81. }
  82. protected override void OnHide()
  83. {
  84. base.OnHide();
  85. Timers.inst.Remove(UpdateTime);
  86. }
  87. protected override void RemoveEventListener()
  88. {
  89. base.RemoveEventListener();
  90. EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, RefreshList);
  91. //EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateRedDot);
  92. }
  93. private void RefreshList()
  94. {
  95. ItemRenderer(_curSelectIndex);
  96. }
  97. private void ItemRenderer(int index)
  98. {
  99. ActivityRechargeCfg lastVipCfg = _rechargeCfgs[index];
  100. ActivityRechargeCfg vipCfg = _rechargeCfgs[index];
  101. UI_ListShowItem item = _ui.m_showItem;
  102. string name = SuitCfgArray.Instance.GetCfg(vipCfg.suitId).name;
  103. item.m_txtName0.text = name;
  104. if (vipCfg.res != "")
  105. {
  106. item.m_cardIcon.visible = true;
  107. item.m_cardBg.visible = true;
  108. item.m_cardIcon.url = "ui://DailyWelfare/" + vipCfg.res;
  109. }
  110. else
  111. {
  112. item.m_cardIcon.visible = false;
  113. item.m_cardBg.visible = false;
  114. }
  115. if (item.m_listGiftBag.data == null)
  116. {
  117. item.m_listGiftBag.itemRenderer = ListRewardItemRender;
  118. item.m_listGiftBag.onClickItem.Add(OnListItemClick);
  119. }
  120. item.m_listGiftBag.data = lastVipCfg.bonusArr;
  121. item.m_listGiftBag.numItems = lastVipCfg.bonusArr.Length;
  122. if (item.m_holder.data == null)
  123. {
  124. DressUpObjUI dressUpObjUI = new DressUpObjUI("SceneSuitFoster");
  125. item.m_holder.data = dressUpObjUI;
  126. _dressUpObjUIs.Add(dressUpObjUI);
  127. }
  128. _dressUpObjUI = item.m_holder.data as DressUpObjUI;
  129. _dressUpObjUI.ResetSceneObj(80, false, true, null, false);
  130. _dressUpObjUI.dressUpObj.PutOnSuitCfg(vipCfg.suitId, true, new int[] { ConstDressUpItemType.BEI_JING }, false, false);
  131. _dressUpObjUI.UpdateWrapper(item.m_holder);
  132. if (item.m_btnShow.data == null)
  133. {
  134. item.m_btnShow.onClick.Add(OnBtnShowClick);
  135. }
  136. item.m_btnShow.data = vipCfg.suitId;
  137. if (item.m_btnGetGiftBag.data == null)
  138. {
  139. item.m_btnGetGiftBag.onClick.Add(OnBtnGetGiftBagClick);
  140. }
  141. item.m_btnGetGiftBag.data = vipCfg.id;
  142. bool isGet = MathUtil.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.VipGetStatus), vipCfg.id);
  143. long limitChargeExp = _activityInfo.CountValue;
  144. item.m_btnGetGiftBag.grayed = limitChargeExp < _rechargeCfgs[index].value;
  145. item.m_txtGiftBag.text = string.Format("活动期间累计获得{0}会员积分({1}/{2})", _rechargeCfgs[index].value, limitChargeExp, _rechargeCfgs[index].value);
  146. }
  147. private void ListRewardItemRender(int index, GObject obj)
  148. {
  149. int[][] rewards = (int[][])obj.parent.data;
  150. UI_ComItem item = UI_ComItem.Proxy(obj);
  151. ItemData itemData = ItemUtil.createItemData(rewards[index]);
  152. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
  153. item.m_txtCount.text = itemData.num.ToString();
  154. item.target.data = itemCfg;
  155. item.m_QualityType.selectedIndex = itemData.rarity - 1;
  156. item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  157. UI_ComItem.ProxyEnd();
  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 id = (int)obj.data;
  179. ActivityGlobalSProxy.ReqGetActivityBonus(_activityId, id).Coroutine();
  180. }
  181. private void OnBtnLeftClick()
  182. {
  183. if (_curSelectIndex == 0) return;
  184. _curSelectIndex = _curSelectIndex - 1;
  185. string name = SuitCfgArray.Instance.GetCfg(_rechargeCfgs[_curSelectIndex].suitId).name;
  186. _ui.m_packageName.text = name;
  187. UpdateSuitView();
  188. //UpdateRedDot();
  189. }
  190. private void OnBtnRightClick()
  191. {
  192. if (_curSelectIndex == _rechargeCfgs.Count - 1) return;
  193. _curSelectIndex = _curSelectIndex + 1;
  194. string name = SuitCfgArray.Instance.GetCfg(_rechargeCfgs[_curSelectIndex].suitId).name;
  195. _ui.m_packageName.text = name;
  196. UpdateSuitView();
  197. //UpdateRedDot();
  198. }
  199. private void OnBtnChargeClick()
  200. {
  201. ViewManager.Show<StoreView>(new object[] { ConstStoreTabId.STORE_CHARGE, ConstStoreSubId.STORE_CHARGE });
  202. }
  203. private void UpdateSuitView()
  204. {
  205. _ui.m_btnLeft.visible = _curSelectIndex == 0 ? false : true;
  206. _ui.m_btnRight.visible = _curSelectIndex < _rechargeCfgs.Count - 1 ? true : false;
  207. ItemRenderer(_curSelectIndex);
  208. }
  209. private void UpdateTime(object param)
  210. {
  211. long curTime = TimeHelper.ServerNow();
  212. long endTime = _activityInfo.EndTime;
  213. _ui.m_txtTime.text = TimeUtil.FormattingTimeTo_DDHHmm(endTime - curTime);
  214. }
  215. private void OnListItemClick(EventContext context)
  216. {
  217. GComponent comItem = (context.data as GComponent);
  218. ItemCfg itemCfg = comItem.data as ItemCfg;
  219. GoodsItemTipsController.ShowItemTips(itemCfg.id);
  220. }
  221. private void OnBtnBackClick()
  222. {
  223. ViewManager.GoBackFrom(typeof(NewLimitChargeView).FullName);
  224. }
  225. }
  226. }