using FairyGUI; using UI.ActivityMain; using System.Collections; using System.Collections.Generic; using ET; using static GFGGame.ShopSProxy; using UI.CommonGame; namespace GFGGame { class WeeklyGiftTipsView : BaseWindow { private UI_WeeklyGiftTipsUI _ui; private int giftShopId = 0; public override void Dispose() { if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_WeeklyGiftTipsUI.PACKAGE_NAME; _ui = UI_WeeklyGiftTipsUI.Create(); this.viewCom = _ui.target; modal = true; this.viewCom.Center(); viewAnimationType = EnumViewAnimationType.ZOOM_CENTER; _ui.m_rewardList.itemRenderer = ListItemRender; _ui.m_rewardList.onClickItem.Add(OnListSelectorItemClick); _ui.m_backBtn.onClick.Add(OnClickChange); _ui.m_buyBtn.target.onClick.Add(OnClickBuy); } protected override void OnShown() { base.OnShown(); ActivityOpenCfg activityCfg = ActivityOpenCfgArray.Instance.GetCfg(ActivityDataManager.Instance.GetCurOpenActiveByType(101)); giftShopId = activityCfg.paramsArr[0]; if (giftShopId != 0) { var shopCfg = ShopCfgArray.Instance.GetCfg(giftShopId); ItemCfg item = ItemCfgArray.Instance.GetCfg(shopCfg.itemId); _ui.m_rewardList.numItems = item.itemsArr.Length; } else { _ui.m_rewardList.numItems = 0; } UpdateBtn(); } protected override void OnHide() { base.OnHide(); } protected override void AddEventListener() { base.AddEventListener(); EventAgent.AddEventListener(ConstMessage.SHOP_BUY, UpdateBtn); } protected override void RemoveEventListener() { base.RemoveEventListener(); EventAgent.RemoveEventListener(ConstMessage.SHOP_BUY, UpdateBtn); } private void OnClickChange() { this.Hide(); } private void ListItemRender(int index, GObject obj) { UI_ComItem uiItemChild = UI_ComItem.Proxy(obj); var shopCfg = ShopCfgArray.Instance.GetCfg(giftShopId); var itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId); int[][] result; result = itemCfg.itemsArr; var itemArr = result[index]; var itemCfgChild = ItemCfgArray.Instance.GetCfg(itemArr[0]); uiItemChild.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfgChild); uiItemChild.m_txtCount.text = itemArr[1].ToString(); uiItemChild.target.data = itemCfgChild; uiItemChild.m_QualityType.selectedIndex = itemCfgChild.rarity - 1; UI_ComItem.ProxyEnd(); } //弹出物品详细描述框 private void OnListSelectorItemClick(EventContext context) { GComponent item = context.data as GComponent; ItemCfg itemCfg = item.data as ItemCfg; GoodsItemTipsController.ShowItemTips(itemCfg.id); } private async void OnClickBuy() { if(giftShopId == 0) { return; } await ReqShopBuy(giftShopId); } private void UpdateBtn() { ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(giftShopId); var remainBuyNum = shopCfg.maxBuyNum - ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id); if (remainBuyNum == 0) { //已售完 _ui.m_buyBtn.target.visible = false; } else { //未售完 _ui.m_buyBtn.target.visible = true; } _ui.m_buyBtn.m_descText.text = string.Format("{0}元购买", shopCfg.configPrice); _ui.m_descText.text = string.Format("限购次数:{0}/{1}", ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id) ,shopCfg.maxBuyNum); } } }