NewLimitChargeView.cs 9.2 KB

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