NewLimitChargeView.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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_StoreChargeAddUpUI.PACKAGE_NAME;
  47. _ui = UI_NewLimitChargeUI.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. _ui.m_btnBack.onClick.Add(OnBtnBackClick);
  60. _ui.m_btnCharge.onClick.Add(OnBtnChargeClick);
  61. }
  62. protected override void AddEventListener()
  63. {
  64. base.AddEventListener();
  65. EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, RefreshList);
  66. //EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateRedDot);
  67. }
  68. protected override void OnShown()
  69. {
  70. base.OnShown();
  71. //_curSelectIndex = Math.Max(0, RoleDataManager.vipLv - 1);
  72. //_ui.m_list.selectedIndex = _curSelectIndex;
  73. //_ui.m_list.ScrollToView(_curSelectIndex);
  74. //_activityId = 501;
  75. _activityId = (int)(this.viewData as object[])[0];
  76. _rechargeCfgs = ActivityRechargeCfgArray.Instance.GetCfgsByactivityId(_activityId);
  77. _activityInfo = ActivityGlobalDataManager.Instance.GetActivityInfo(_activityId);
  78. //UpdateRedDot();
  79. RefreshList();
  80. _ui.m_btnLeft.visible = _curSelectIndex == 0 ? false : true;
  81. _ui.m_btnRight.visible = _curSelectIndex < _ui.m_list.numItems - 1 ? true : false;
  82. Timers.inst.Add(1, 0, UpdateTime);
  83. }
  84. protected override void OnHide()
  85. {
  86. base.OnHide();
  87. if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0);
  88. Timers.inst.Remove(UpdateTime);
  89. }
  90. protected override void RemoveEventListener()
  91. {
  92. base.RemoveEventListener();
  93. EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, RefreshList);
  94. //EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateRedDot);
  95. }
  96. private void RefreshList()
  97. {
  98. _ui.m_list.numItems = _rechargeCfgs.Count;
  99. }
  100. private void ListItemRenderer(int index, GObject obj)
  101. {
  102. ActivityRechargeCfg lastVipCfg = _rechargeCfgs[index];
  103. ActivityRechargeCfg vipCfg = _rechargeCfgs[index];
  104. UI_ListShowItem item = UI_ListShowItem.Proxy(obj);
  105. string name = SuitCfgArray.Instance.GetCfg(vipCfg.suitId).name;
  106. item.m_txtName0.text = name.Length > 0 ? name.Substring(0, 1) : "";
  107. item.m_txtName1.text = name.Length > 1 ? name.Substring(1, 1) : "";
  108. item.m_txtName2.text = name.Length > 2 ? name.Substring(2, 1) : "";
  109. item.m_txtName3.text = name.Length > 3 ? name.Substring(3, 1) : "";
  110. item.m_txtName4.text = name.Length > 4 ? name.Substring(4) : "";
  111. _ui.m_packageName.text = name;
  112. if (item.m_listGiftBag.data == null)
  113. {
  114. item.m_listGiftBag.itemRenderer = ListRewardItemRender;
  115. item.m_listGiftBag.onClickItem.Add(OnListItemClick);
  116. }
  117. item.m_listGiftBag.data = lastVipCfg.bonusArr;
  118. item.m_listGiftBag.numItems = lastVipCfg.bonusArr.Length;
  119. if (item.m_holder.data == null)
  120. {
  121. DressUpObjUI dressUpObjUI = new DressUpObjUI("SceneSuitFoster");
  122. item.m_holder.data = dressUpObjUI;
  123. _dressUpObjUIs.Add(dressUpObjUI);
  124. }
  125. _dressUpObjUI = item.m_holder.data as DressUpObjUI;
  126. _dressUpObjUI.ResetSceneObj(80, false, true, null, false);
  127. _dressUpObjUI.dressUpObj.PutOnSuitCfg(vipCfg.suitId, true, new int[] { ConstDressUpItemType.BEI_JING }, false, false);
  128. _dressUpObjUI.UpdateWrapper(item.m_holder);
  129. if (item.m_btnShow.data == null)
  130. {
  131. item.m_btnShow.onClick.Add(OnBtnShowClick);
  132. }
  133. item.m_btnShow.data = vipCfg.suitId;
  134. if (item.m_btnGetGiftBag.data == null)
  135. {
  136. item.m_btnGetGiftBag.onClick.Add(OnBtnGetGiftBagClick);
  137. }
  138. item.m_btnGetGiftBag.data = vipCfg.id;
  139. bool isGet = MathUtil.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.VipGetStatus), vipCfg.id);
  140. long limitChargeExp = _activityInfo.CountValue;
  141. item.m_btnGetGiftBag.grayed = limitChargeExp < _rechargeCfgs[index].value;
  142. //RedDotController.Instance.SetComRedDot(item.m_btnGetGiftBag, !isGet && RoleDataManager.vipLv >= vipCfg.id);
  143. //bool canGet = GameGlobal.myNumericComponent.GetAsInt(NumericType.VipWeekGetStatus) == 0 && RoleDataManager.vipLv == vipCfg.id;
  144. //long limitChargeExp = _activityInfo.CountValue;// GameGlobal.myNumericComponent.GetAsInt(NumericType.TotalRechargeScore);
  145. item.m_txtGiftBag.text = string.Format("活动期间累计获得{0}会员积分({1}/{2})", _rechargeCfgs[index].value, limitChargeExp, _rechargeCfgs[index].value);
  146. UI_ListVipItem.ProxyEnd();
  147. }
  148. private void ListRewardItemRender(int index, GObject obj)
  149. {
  150. int[][] rewards = (int[][])obj.parent.data;
  151. UI_ComItem item = UI_ComItem.Proxy(obj);
  152. ItemData itemData = ItemUtil.createItemData(rewards[index]);
  153. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
  154. item.m_txtCount.text = itemData.num.ToString();
  155. item.target.data = itemCfg;
  156. item.m_QualityType.selectedIndex = itemData.rarity - 1;
  157. item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  158. UI_ComItem.ProxyEnd();
  159. }
  160. private void OnBtnShowClick(EventContext context)
  161. {
  162. GObject obj = context.sender as GObject;
  163. int suitId = (int)obj.data;
  164. int _suitTypeId = 0;
  165. for (int i = 0; i < SuitGuideMenuCfgArray.Instance.dataArray.Length; i++)
  166. {
  167. string[] suitIds = SuitGuideMenuCfgArray.Instance.dataArray[i].suitIds.Split(';');
  168. if (Array.IndexOf(suitIds, suitId.ToString()) >= 0)
  169. {
  170. _suitTypeId = SuitGuideMenuCfgArray.Instance.dataArray[i].id;
  171. break;
  172. }
  173. }
  174. ViewManager.Show<SuitShowView>(new object[] { _suitTypeId, suitId, new List<int>() { suitId }, false });
  175. }
  176. private void OnBtnGetGiftBagClick(EventContext context)
  177. {
  178. GObject obj = context.sender as GObject;
  179. int id = (int)obj.data;
  180. ActivityGlobalSProxy.ReqGetActivityBonus(_activityId, id).Coroutine();
  181. }
  182. private void OnBtnLeftClick()
  183. {
  184. if (_curSelectIndex == 0) return;
  185. _curSelectIndex = _curSelectIndex - 1;
  186. _ui.m_list.ScrollToView(_curSelectIndex, true);
  187. //UpdateRedDot();
  188. }
  189. private void OnBtnRightClick()
  190. {
  191. if (_curSelectIndex == _ui.m_list.numItems - 1) return;
  192. _curSelectIndex = _curSelectIndex + 1;
  193. _ui.m_list.ScrollToView(_curSelectIndex, true);
  194. //UpdateRedDot();
  195. }
  196. private void OnBtnChargeClick()
  197. {
  198. ViewManager.Show<StoreView>(new object[] { ConstStoreTabId.STORE_CHARGE, ConstStoreSubId.STORE_CHARGE });
  199. }
  200. private void UpdateSuitView()
  201. {
  202. _curSelectIndex = _ui.m_list.GetFirstChildInView();
  203. _ui.m_list.selectedIndex = _curSelectIndex;
  204. _ui.m_btnLeft.visible = _curSelectIndex == 0 ? false : true;
  205. _ui.m_btnRight.visible = _curSelectIndex < _ui.m_list.numItems - 1 ? true : false;
  206. }
  207. private void UpdateTime(object param)
  208. {
  209. long curTime = TimeHelper.ServerNow();
  210. long endTime = _activityInfo.EndTime;
  211. _ui.m_txtTime.text = TimeUtil.FormattingTimeTo_DDHHmm(endTime - curTime);
  212. }
  213. //private void UpdateRedDot()
  214. //{
  215. // bool leftRed = false;
  216. // bool rightRed = false;
  217. // VipCfg[] vipCfgs = VipCfgArray.Instance.dataArray;
  218. // for (int i = 1; i < vipCfgs.Length; i++)
  219. // {
  220. // bool isGet = MathUtil.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.VipGetStatus), vipCfgs[i].id);
  221. // bool red = !isGet && RoleDataManager.vipLv >= vipCfgs[i].id;
  222. // if (red && _curSelectIndex > i - 1)
  223. // {
  224. // leftRed = true;
  225. // break;
  226. // }
  227. // if (red && _curSelectIndex + 1 < i)
  228. // {
  229. // rightRed = true;
  230. // break;
  231. // }
  232. // }
  233. // if (GameGlobal.myNumericComponent.GetAsInt(NumericType.VipWeekGetStatus) == 0 && RoleDataManager.vipLv > 0 && _curSelectIndex > RoleDataManager.vipLv - 1) { leftRed = true; }
  234. // if (GameGlobal.myNumericComponent.GetAsInt(NumericType.VipWeekGetStatus) == 0 && RoleDataManager.vipLv > 0 && _curSelectIndex + 1 < RoleDataManager.vipLv) { rightRed = true; }
  235. // RedDotController.Instance.SetComRedDot(_ui.m_btnLeft, leftRed);
  236. // RedDotController.Instance.SetComRedDot(_ui.m_btnRight, rightRed);
  237. //}
  238. private void OnListItemClick(EventContext context)
  239. {
  240. GComponent comItem = (context.data as GComponent);
  241. ItemCfg itemCfg = comItem.data as ItemCfg;
  242. GoodsItemTipsController.ShowItemTips(itemCfg.id);
  243. }
  244. private void OnBtnBackClick()
  245. {
  246. ViewManager.GoBackFrom(typeof(NewLimitChargeView).FullName);
  247. }
  248. }
  249. }