| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 | using System.Threading.Tasks;using ET;using FairyGUI;using UI.RechargeStore;namespace GFGGame{    public class GiftBagBuyView : BaseWindow    {        private UI_GiftBagBuyUI _ui;        private int _giftId;        public override void Dispose()        {            if (_ui != null)            {                _ui.Dispose();            }            _ui = null;            base.Dispose();        }        protected override void OnHide()        {            base.OnHide();        }        protected override void OnInit()        {            base.OnInit();            packageName = UI_GiftBagBuyUI.PACKAGE_NAME;            _ui = UI_GiftBagBuyUI.Create();            this.viewCom = _ui.target;            this.viewCom.Center();            this.modal = true;            viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;            _ui.m_btnBuy.onClick.Add(OnBtnBuyClick);            _ui.m_list.itemRenderer = ListItemRender;        }        protected override void OnShown()        {            base.OnShown();            _giftId = (int)this.viewData;            GiftBagCfg cfg = GiftBagCfgArray.Instance.GetCfg(_giftId);            _ui.m_txtName.text = cfg.name;            _ui.m_loaIcon.url = ResPathUtil.GetIconPath(cfg.res, "png");//string.Format("ui://RechargeStore/{0}", cfg.res);            _ui.m_list.numItems = cfg.itemsArr.Length;            _ui.m_c1.selectedIndex = RechargeDataManager.Instance.GetGiftStateById(_giftId) ? 0 : 1;            if (cfg.lockType == LockType.STORY_LV)            {                StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(cfg.storyLevelId);                _ui.m_txtLock.text = string.Format("通关{0}-{1}解锁", StoryUtil.GetChapterOrder(storyLevelCfg.chapterId), storyLevelCfg.order);            }            else if (cfg.lockType == LockType.ROLE_LV)            {                _ui.m_txtLock.text = string.Format("角色达到{0}级解锁", cfg.lv);            }            int buyNum = RechargeDataManager.Instance.GetGiftBuyNumById(cfg.id);            _ui.m_txtLimit.text = string.Format("{0}({1}/{2})", RechargeDataManager.Instance.refreshType[cfg.refreshType], StringUtil.GetColorText(buyNum.ToString(), "#DA8870"), cfg.maxBuyNum);            if (cfg.refreshType == RefreshType.NONE) _ui.m_txtLimit.text = "永久限购";            _ui.m_txtEndTime.text = RechargeDataManager.Instance.GetEndTime(cfg.id);            _ui.m_grpEndTime.visible = cfg.endTime != "";            _ui.m_txtOriginalPrice.text = NumberUtil.ChangeNumberUnit(cfg.originalPrice);// cfg.originalPrice.ToString();            if (cfg.price > 0 && cfg.costType != CostType.FREE)            {                _ui.m_grpOriginalPrice.visible = cfg.originalPrice > 0;                _ui.m_grpIcon.visible = true;                _ui.m_txtPrice.text = NumberUtil.ChangeNumberUnit(cfg.price);// cfg.price.ToString();                if (cfg.costType == CostType.RMB)                {                    _ui.m_loaPriceIcon.visible = false;                    _ui.m_txtIcon.visible = true;                    _ui.m_txtIcon.text = "¥";                }                else                {                    ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.costId);                    _ui.m_loaPriceIcon.url = ResPathUtil.GetIconPath(itemCfg);                    _ui.m_loaPriceIcon.visible = true;                    _ui.m_txtIcon.visible = false;                }            }            else            {                _ui.m_grpIcon.visible = false;                _ui.m_grpOriginalPrice.visible = false;                _ui.m_txtPrice.text = "免费";            }        }        private void ListItemRender(int index, GObject item)        {            GiftBagCfg cfg = GiftBagCfgArray.Instance.GetCfg(_giftId);            ItemData itemData = ItemUtil.createItemData(cfg.itemsArr[index]);            if (item.data == null)            {                item.data = new ItemView(item as GComponent);            }            (item.data as ItemView).SetData(itemData);        }        private async void OnBtnBuyClick()        {            GiftBagCfg cfg = GiftBagCfgArray.Instance.GetCfg(_giftId);            if (cfg.costType == CostType.MONEY || cfg.costType == CostType.ITEM)            {                int hasNum = ItemDataManager.GetItemNum(cfg.costId);                if (hasNum < cfg.price)                {                    PromptController.Instance.ShowFloatTextPrompt("道具不足");                    return;                }            }            bool result = await RechargeSProxy.ReqBuyGiftBag(_giftId);            if (result)            {                LogServerHelper.SendNodeLog((int)PlayParticipationEnum.SHANG_CHENG, 2);                this.Hide();                if (cfg.costType == CostType.RMB)                {                    PromptController.Instance.ShowFloatTextPrompt("虚拟充值购买成功");                }            }        }    }}
 |