123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- using System.Collections.Generic;
- using ET;
- using FairyGUI;
- using UI.Bag;
- using UI.CommonGame;
- using UnityEngine;
- namespace GFGGame
- {
- public class BagView : BaseWindow
- {
- private UI_BagUI _ui;
- private ValueBarController _valueBarController;
- // private List<ItemView> _listItemViews = new List<ItemView>();
- public override void Dispose()
- {
- base.Dispose();
- if (_valueBarController != null)
- {
- _valueBarController.Dispose();
- _valueBarController = null;
- }
- // for (int i = 0; i < _listItemViews.Count; i++)
- // {
- // _listItemViews[i].Dispose();
- // _listItemViews[i] = null;
- // }
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_BagUI.PACKAGE_NAME;
- _ui = UI_BagUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- _valueBarController = new ValueBarController(_ui.m_comValueBar);
- _ui.m_btnback.onClick.Add(OnBtnBackClick);
- _ui.m_list.SetVirtual();
- _ui.m_list.itemRenderer = ListItemRender;
- _ui.m_list.onClickItem.Add(OnListItemClick);
- _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("tc_bjbj");
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, UpdateList);
- }
-
- protected override void OnShown()
- {
- base.OnShown();
- _valueBarController.OnShown();
- UpdateList();
- }
- protected override void OnHide()
- {
- _valueBarController.OnHide();
- if (_ui.m_list.numItems > 0)
- {
- _ui.m_list.ScrollToView(0);
- }
- _ui.m_list.numItems = 0;
- base.OnHide();
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, UpdateList);
- }
- private void UpdateList()
- {
- _ui.m_list.numItems = BagDataManager.Instance.BagDatas.Count;
- }
- private void ListItemRender(int index, GObject obj)
- {
- ItemData itemData = BagDataManager.Instance.BagDatas[index];
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
- UI_ListItem item = UI_ListItem.Proxy(obj);
- item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
- item.m_txtCount.SetVar("count", itemData.num.ToString()).FlushVars();
- item.target.data = itemCfg;
- //是礼包就加入红点
- // if (itemCfg.itemType == ConstItemType.USEABLE)
- // {
- // if (itemCfg.subType == ConstItemSubType.USEABLE_GIFT_BAG_SELECTABLE ||
- // itemCfg.subType == ConstItemSubType.USEABLE_GIFT_BAG_RANDOM)
- // {
- // RedDotController.Instance.SetComRedDot(item.target, true);
- // }
- // }
- }
- private void OnListItemClick(EventContext context)
- {
- GComponent comItem = (context.data as GComponent);
- ItemCfg itemCfg = comItem.data as ItemCfg;
- //可使用物品
- if (itemCfg.itemType == ConstItemType.USEABLE)
- {
- if (itemCfg.subType == ConstItemSubType.USEABLE_GIFT_BAG_SELECTABLE)
- {
- ViewManager.Show<GiftBoxSelectorView>(itemCfg.id);
- }
- else
- {
- //暂时程序走不到这里,这里是以前用来使用物品的一个界面---20230607--hxj注释
- ViewManager.Show<BagExchangeView>(itemCfg.id);
- }
- }
- else
- {
- object[] sourceDatas = new object[]
- { itemCfg.id, new object[] { typeof(BagView).FullName, this.viewData } };
- GoodsItemTipsController.ShowItemTips(itemCfg.id, sourceDatas);
- }
- }
- private void OnBtnBackClick()
- {
- ViewManager.GoBackFrom(typeof(BagView).FullName);
- }
- }
- }
|