using UI.Store; using UI.CommonGame; using FairyGUI; using System.Collections.Generic; using ET; using System; using Hutool; using UI.DailyWelfare; namespace GFGGame { public class NewLimitChargeView : BaseWindow { private UI_NewLimitChargeUI _ui; private List _shopCfgs; private DressUpObjUI _dressUpObjUI; private List _dressUpObjUIs = new List(); private int _curSelectIndex = 0; private int _activityId = 0; private ActivityInfo _activityInfo; private List _rechargeCfgs; public override void Dispose() { if (_dressUpObjUI != null) { _dressUpObjUI.Dispose(); _dressUpObjUI = null; } for (int i = 0; i < _dressUpObjUIs.Count; i++) { if (_dressUpObjUIs[i] != null) { _dressUpObjUIs[i].Dispose(); _dressUpObjUIs[i] = null; } } if (_ui != null) { _ui.Dispose(); } _ui = null; base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_StoreChargeAddUpUI.PACKAGE_NAME; _ui = UI_NewLimitChargeUI.Create(); this.viewCom = _ui.target; isfullScreen = true; this.clickBlankToClose = false; this.bringToFontOnClick = false; _dressUpObjUI = new DressUpObjUI("SceneSuitFoster"); _ui.m_list.itemRenderer = ListItemRenderer; _ui.m_list.SetVirtual(); _ui.m_list.scrollPane.onScrollEnd.Add(UpdateSuitView); _ui.m_list.scrollPane.decelerationRate = 0.8f; _ui.m_btnLeft.onClick.Add(OnBtnLeftClick); _ui.m_btnRight.onClick.Add(OnBtnRightClick); _ui.m_btnBack.onClick.Add(OnBtnBackClick); _ui.m_btnCharge.onClick.Add(OnBtnChargeClick); } protected override void AddEventListener() { base.AddEventListener(); EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, RefreshList); //EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateRedDot); } protected override void OnShown() { base.OnShown(); //_curSelectIndex = Math.Max(0, RoleDataManager.vipLv - 1); //_ui.m_list.selectedIndex = _curSelectIndex; //_ui.m_list.ScrollToView(_curSelectIndex); //_activityId = 501; _activityId = (int)(this.viewData as object[])[0]; _rechargeCfgs = ActivityRechargeCfgArray.Instance.GetCfgsByactivityId(_activityId); _activityInfo = ActivityGlobalDataManager.Instance.GetActivityInfo(_activityId); //UpdateRedDot(); RefreshList(); _ui.m_btnLeft.visible = _curSelectIndex == 0 ? false : true; _ui.m_btnRight.visible = _curSelectIndex < _ui.m_list.numItems - 1 ? true : false; Timers.inst.Add(1, 0, UpdateTime); } protected override void OnHide() { base.OnHide(); if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0); Timers.inst.Remove(UpdateTime); } protected override void RemoveEventListener() { base.RemoveEventListener(); EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, RefreshList); //EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateRedDot); } private void RefreshList() { _ui.m_list.numItems = _rechargeCfgs.Count; } private void ListItemRenderer(int index, GObject obj) { ActivityRechargeCfg lastVipCfg = _rechargeCfgs[index]; ActivityRechargeCfg vipCfg = _rechargeCfgs[index]; UI_ListShowItem item = UI_ListShowItem.Proxy(obj); string name = SuitCfgArray.Instance.GetCfg(vipCfg.suitId).name; item.m_txtName0.text = name.Length > 0 ? name.Substring(0, 1) : ""; item.m_txtName1.text = name.Length > 1 ? name.Substring(1, 1) : ""; item.m_txtName2.text = name.Length > 2 ? name.Substring(2, 1) : ""; item.m_txtName3.text = name.Length > 3 ? name.Substring(3, 1) : ""; item.m_txtName4.text = name.Length > 4 ? name.Substring(4) : ""; _ui.m_packageName.text = name; if (item.m_listGiftBag.data == null) { item.m_listGiftBag.itemRenderer = ListRewardItemRender; item.m_listGiftBag.onClickItem.Add(OnListItemClick); } item.m_listGiftBag.data = lastVipCfg.bonusArr; item.m_listGiftBag.numItems = lastVipCfg.bonusArr.Length; if (item.m_holder.data == null) { DressUpObjUI dressUpObjUI = new DressUpObjUI("SceneSuitFoster"); item.m_holder.data = dressUpObjUI; _dressUpObjUIs.Add(dressUpObjUI); } _dressUpObjUI = item.m_holder.data as DressUpObjUI; _dressUpObjUI.ResetSceneObj(80, false, true, null, false); _dressUpObjUI.dressUpObj.PutOnSuitCfg(vipCfg.suitId, true, new int[] { ConstDressUpItemType.BEI_JING }, false, false); _dressUpObjUI.UpdateWrapper(item.m_holder); if (item.m_btnShow.data == null) { item.m_btnShow.onClick.Add(OnBtnShowClick); } item.m_btnShow.data = vipCfg.suitId; if (item.m_btnGetGiftBag.data == null) { item.m_btnGetGiftBag.onClick.Add(OnBtnGetGiftBagClick); } item.m_btnGetGiftBag.data = vipCfg.id; bool isGet = MathUtil.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.VipGetStatus), vipCfg.id); long limitChargeExp = _activityInfo.CountValue; item.m_btnGetGiftBag.grayed = limitChargeExp < _rechargeCfgs[index].value; //RedDotController.Instance.SetComRedDot(item.m_btnGetGiftBag, !isGet && RoleDataManager.vipLv >= vipCfg.id); //bool canGet = GameGlobal.myNumericComponent.GetAsInt(NumericType.VipWeekGetStatus) == 0 && RoleDataManager.vipLv == vipCfg.id; //long limitChargeExp = _activityInfo.CountValue;// GameGlobal.myNumericComponent.GetAsInt(NumericType.TotalRechargeScore); item.m_txtGiftBag.text = string.Format("活动期间累计获得{0}会员积分({1}/{2})", _rechargeCfgs[index].value, limitChargeExp, _rechargeCfgs[index].value); UI_ListVipItem.ProxyEnd(); } private void ListRewardItemRender(int index, GObject obj) { int[][] rewards = (int[][])obj.parent.data; UI_ComItem item = UI_ComItem.Proxy(obj); ItemData itemData = ItemUtil.createItemData(rewards[index]); ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id); item.m_txtCount.text = itemData.num.ToString(); item.target.data = itemCfg; item.m_QualityType.selectedIndex = itemData.rarity - 1; item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg); UI_ComItem.ProxyEnd(); } private void OnBtnShowClick(EventContext context) { GObject obj = context.sender as GObject; int suitId = (int)obj.data; int _suitTypeId = 0; for (int i = 0; i < SuitGuideMenuCfgArray.Instance.dataArray.Length; i++) { string[] suitIds = SuitGuideMenuCfgArray.Instance.dataArray[i].suitIds.Split(';'); if (Array.IndexOf(suitIds, suitId.ToString()) >= 0) { _suitTypeId = SuitGuideMenuCfgArray.Instance.dataArray[i].id; break; } } ViewManager.Show(new object[] { _suitTypeId, suitId, new List() { suitId }, false }); } private void OnBtnGetGiftBagClick(EventContext context) { GObject obj = context.sender as GObject; int id = (int)obj.data; ActivityGlobalSProxy.ReqGetActivityBonus(_activityId, id).Coroutine(); } private void OnBtnLeftClick() { if (_curSelectIndex == 0) return; _curSelectIndex = _curSelectIndex - 1; _ui.m_list.ScrollToView(_curSelectIndex, true); //UpdateRedDot(); } private void OnBtnRightClick() { if (_curSelectIndex == _ui.m_list.numItems - 1) return; _curSelectIndex = _curSelectIndex + 1; _ui.m_list.ScrollToView(_curSelectIndex, true); //UpdateRedDot(); } private void OnBtnChargeClick() { ViewManager.Show(new object[] { ConstStoreTabId.STORE_CHARGE, ConstStoreSubId.STORE_CHARGE }); } private void UpdateSuitView() { _curSelectIndex = _ui.m_list.GetFirstChildInView(); _ui.m_list.selectedIndex = _curSelectIndex; _ui.m_btnLeft.visible = _curSelectIndex == 0 ? false : true; _ui.m_btnRight.visible = _curSelectIndex < _ui.m_list.numItems - 1 ? true : false; } private void UpdateTime(object param) { long curTime = TimeHelper.ServerNow(); long endTime = _activityInfo.EndTime; _ui.m_txtTime.text = TimeUtil.FormattingTimeTo_DDHHmm(endTime - curTime); } //private void UpdateRedDot() //{ // bool leftRed = false; // bool rightRed = false; // VipCfg[] vipCfgs = VipCfgArray.Instance.dataArray; // for (int i = 1; i < vipCfgs.Length; i++) // { // bool isGet = MathUtil.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.VipGetStatus), vipCfgs[i].id); // bool red = !isGet && RoleDataManager.vipLv >= vipCfgs[i].id; // if (red && _curSelectIndex > i - 1) // { // leftRed = true; // break; // } // if (red && _curSelectIndex + 1 < i) // { // rightRed = true; // break; // } // } // if (GameGlobal.myNumericComponent.GetAsInt(NumericType.VipWeekGetStatus) == 0 && RoleDataManager.vipLv > 0 && _curSelectIndex > RoleDataManager.vipLv - 1) { leftRed = true; } // if (GameGlobal.myNumericComponent.GetAsInt(NumericType.VipWeekGetStatus) == 0 && RoleDataManager.vipLv > 0 && _curSelectIndex + 1 < RoleDataManager.vipLv) { rightRed = true; } // RedDotController.Instance.SetComRedDot(_ui.m_btnLeft, leftRed); // RedDotController.Instance.SetComRedDot(_ui.m_btnRight, rightRed); //} private void OnListItemClick(EventContext context) { GComponent comItem = (context.data as GComponent); ItemCfg itemCfg = comItem.data as ItemCfg; GoodsItemTipsController.ShowItemTips(itemCfg.id); } private void OnBtnBackClick() { ViewManager.GoBackFrom(typeof(NewLimitChargeView).FullName); } } }