| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 | using UI.Store;using UI.CommonGame;using FairyGUI;using System.Collections.Generic;using ET;using System;namespace GFGGame{    public class StoreMonthView : BaseWindow    {        private UI_StoreMonthUI _ui;        private ValueBarController _valueBarController;        private List<ShopCfg> _shopCfgs;        public override void Dispose()        {            if (_valueBarController != null)            {                _valueBarController.Dispose();                _valueBarController = null;            }            if (_ui != null)            {                _ui.Dispose();            }            _ui = null;            base.Dispose();        }        protected override void OnInit()        {            base.OnInit();            packageName = UI_StoreMonthUI.PACKAGE_NAME;            _ui = UI_StoreMonthUI.Create();            this.viewCom = _ui.target;            isfullScreen = true;            this.clickBlankToClose = false;            _valueBarController = new ValueBarController(_ui.m_valueBar);            _ui.m_list.itemRenderer = ListItemRenderer;            _ui.m_btnRule.onClick.Add(RuleController.ShowRuleView);            _ui.m_btnBuy.target.onClick.Add(OnBtnBuyCardClick);            _ui.m_btnGet.onClick.Add(OnBtnGetClick);            _ui.m_btnBlackReward.onClick.Add(OnBtnBlackRewardClick);        }        protected override void AddEventListener()        {            base.AddEventListener();            EventAgent.AddEventListener(ConstMessage.SHOP_BUY, UpdateView);        }        protected override void OnShown()        {            base.OnShown();            _valueBarController.OnShown();            UpdateView();        }        protected override void OnHide()        {            base.OnHide();            _valueBarController.OnHide();        }        protected override void RemoveEventListener()        {            base.RemoveEventListener();            EventAgent.RemoveEventListener(ConstMessage.SHOP_BUY, UpdateView);        }        private void OnBtnBlackRewardClick()        {            ViewManager.Show<StoreBlackCardRewardView>();        }        private void UpdateView()        {            int menu2 = (int)this.viewData;            _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_MONTH_CARD, menu2);            _shopCfgs = ShopDataManager.Instance.RemoveNotOpenCfg(_shopCfgs);            _shopCfgs = ShopDataManager.Instance.SortShopGoodsCfgs(_shopCfgs);            _ui.m_list.numItems = _shopCfgs.Count;            MonthlyCardPrivilegeCfg privilegeCfg = MonthlyCardPrivilegeCfgArray.Instance.GetCfg(MonthCardPrivilegeType.Privilege1);            string iconUrl = "";            bool isFirstBuy = false;            bool isGot = false;            long endTime = 0;            int privilegeCount = 0;            MonthlyCardCfg monthCfg = null;            switch (menu2)            {                case ConstStoreSubId.STORE_MONTH_GLOAD_CARD:                    iconUrl = "ui://Store/MonthCard_Icon";                    monthCfg = MonthlyCardCfgArray.Instance.GetCfg(MonthCardType.Gold);                    isFirstBuy = GameGlobal.myNumericComponent.GetAsInt(NumericType.MonthCardGoldFirstBuy) <= 0;                    endTime = GameGlobal.myNumericComponent.GetAsLong(NumericType.MonthCardGoldEndTime);                    isGot = GameGlobal.myNumericComponent.GetAsInt(NumericType.MonthCardGoldReward) > 0;                    for (int i = 0; i < MonthlyCardPrivilegeCfgArray.Instance.dataArray.Length; i++)                    {                        if (MonthlyCardPrivilegeCfgArray.Instance.dataArray[i].value1Arr[0] > 0)                        {                            privilegeCount++;                        }                    }                    _ui.m_txtMoneyCount.text = privilegeCfg.value1Arr[0].ToString();                    _ui.m_txtDailyMoneyCount.text = privilegeCfg.value1Arr[1].ToString();                    _ui.m_btnBlackReward.visible = false;                    _ui.m_btnRule.data = 300010;                    break;                case ConstStoreSubId.STORE_MONTH_BLACK_CARD:                    iconUrl = "ui://Store/MonthCard_Icon";                    monthCfg = MonthlyCardCfgArray.Instance.GetCfg(MonthCardType.BlackGold);                    isFirstBuy = GameGlobal.myNumericComponent.GetAsInt(NumericType.MonthCardBlackGoldFirstBuy) <= 0;                    endTime = GameGlobal.myNumericComponent.GetAsLong(NumericType.MonthCardBlackGoldEndTime);                    isGot = GameGlobal.myNumericComponent.GetAsInt(NumericType.MonthCardBlackGoldReward) > 0;                    for (int i = 0; i < MonthlyCardPrivilegeCfgArray.Instance.dataArray.Length; i++)                    {                        if (MonthlyCardPrivilegeCfgArray.Instance.dataArray[i].value2Arr[0] > 0)                        {                            privilegeCount++;                        }                    }                    _ui.m_txtMoneyCount.text = privilegeCfg.value2Arr[0].ToString();                    _ui.m_txtDailyMoneyCount.text = privilegeCfg.value2Arr[1].ToString();                    _ui.m_btnBlackReward.visible = true;                    _ui.m_btnRule.data = 300011;                    break;            }            long day = TimeUtil.FormattingTime11(TimeHelper.ServerNow(), endTime);            _ui.m_txtTime.SetVar("value", day.ToString()).FlushVars();            _ui.m_txtTime.visible = endTime > TimeHelper.ServerNow();            _ui.m_loaCard.url = iconUrl;            ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(monthCfg.shopId);            _ui.m_btnBuy.m_txtOriginalPrice.text = shopCfg.price.ToString();            _ui.m_btnBuy.m_grpOriginalPrice.visible = isFirstBuy && shopCfg.oncePrice < shopCfg.price;            int price = isFirstBuy ? shopCfg.oncePrice : shopCfg.price;            _ui.m_btnBuy.m_txtPrice.text = price.ToString();            _ui.m_btnBuy.target.data = monthCfg.shopId;            _ui.m_txtTips.SetVar("value", (price * 10).ToString()).FlushVars();            _ui.m_txtTips.SetVar("day", monthCfg.limitDays.ToString()).FlushVars();            _ui.m_loaMoney.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(privilegeCfg.paramsArr[0]).res);            _ui.m_loaDailyMoney.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(privilegeCfg.paramsArr[0]).res);            _ui.m_txtPrivilegeCount.text = privilegeCount.ToString();            _ui.m_txtTPrivilege.SetVar("value", privilegeCount.ToString()).FlushVars();            _ui.m_btnGet.enabled = endTime > TimeHelper.ServerNow() && !isGot;            _ui.m_btnGet.text = isGot ? "已领取" : "领取";            _ui.m_btnGet.data = monthCfg.type; ;        }        private void OnBtnBuyCardClick(EventContext context)        {            GObject obj = context.sender as GObject;            int goodsId = (int)obj.data;            ShopSProxy.ReqShopBuy(goodsId).Coroutine();        }        private async void OnBtnGetClick(EventContext context)        {            GObject obj = context.sender as GObject;            int goodsId = (int)obj.data;            bool result = await ShopSProxy.ReqGetMonthCardReward(goodsId);            if (result)            {                UpdateView();            }        }        private void ListItemRenderer(int index, GObject obj)        {            ShopCfg shopCfg = _shopCfgs[index];            ShopViewManager.Instance.UptadeItem(obj, shopCfg);        }        private async void OnClickBtnBuy(EventContext context)        {            GObject obj = context.sender as GObject;            int index = (int)obj.data;            ShopCfg itemData = _shopCfgs[index];            if (!AntiAddictionController.CheckAntiAddictionRecharge(itemData.price))            {                bool result = await ShopSProxy.ReqShopBuy(itemData.id, 1);                if (result)                {                    UpdateView();                    LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);                }            }        }    }}
 |