123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- using ET;
- using FairyGUI;
- using UI.ActivityMain;
- using UI.CommonGame;
- using static GFGGame.ShopSProxy;
- namespace GFGGame
- {
- public class ZGTHgiftTipsView : BaseWindow
- {
- //直购648
- private UI_ZGTHgiftTipsUI _ui;
- private int giftItemId = 0;
- private ItemCfg itemcfg;
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_ZGTHgiftTipsUI.PACKAGE_NAME;
- _ui = UI_ZGTHgiftTipsUI.Create();
- this.viewCom = _ui.target;
- this.modal = true;
- this.viewCom.Center();
- viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
- _ui.m_Itemlist.itemRenderer = ListItemRender;
- _ui.m_btnBuy.onClick.Add(OnBtnGetClick);
- _ui.m_btnClose.onClick.Add(this.Hide);
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- }
- protected override void OnShown()
- {
- base.OnShown();
-
- ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(ActivityOpenCfgArray.Instance.GetCfg(6001).paramsArr[0]);
- giftItemId = shopCfg.itemId;
- itemcfg = ItemCfgArray.Instance.GetCfg(giftItemId);
- _ui.m_Itemlist.numItems = itemcfg.itemsArr.Length;
- int buyNum = ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id);
- if (shopCfg.maxBuyNum == 0 || buyNum < shopCfg.maxBuyNum)
- {
- _ui.m_btnBuy.visible = true;
- }
- else
- {
- _ui.m_btnBuy.visible = false;
- }
- Timers.inst.Add(1, 0, UpdateTime);
- }
- protected override void OnHide()
- {
- Timers.inst.Remove(UpdateTime);
- base.OnHide();
- }
- private void OnBtnGetClick()
- {
- _ui.m_btnBuy.visible = false;
- ReqShopBuy(itemcfg.id).Coroutine();
- }
- private void UpdateBtn()
- {
- _ui.m_btnBuy.visible = false;
- }
- private void ListItemRender(int index, GObject obj)
- {
- UI_ZGTHRewardItem item = UI_ZGTHRewardItem.Proxy(obj);
- int id = itemcfg.itemsArr[index][0];
- int count = itemcfg.itemsArr[index][1];
- ItemData itemDate = ItemUtil.createItemData(id, count);
- ItemView itemView = new ItemView(item.m_item);
- itemView.SetData(itemDate);
- item.m_name.text = ItemCfgArray.Instance.GetCfg(itemcfg.id).name;
- UI_ZGTHRewardItem.ProxyEnd();
- }
- private void UpdateTime(object param)
- {
- var activityInfo = ActivityGlobalDataManager.Instance.GetActivityInfo(6002);
- long endTime = 0;
- if (activityInfo != null)
- {
- endTime = activityInfo.EndTime;
- }
- var leftTime = endTime - TimeHelper.ServerNow();
- if (leftTime <= 0)
- {
- _ui.m_timeText.text = "";
- _ui.m_btnBuy.visible = false;
- Timers.inst.Remove(UpdateTime);
- return;
- }
- _ui.m_timeText.text = TimeUtil.FormattingTimeTo_DDHHmm((int)leftTime);
- }
- }
- }
|