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 _listItemViews = new List(); 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("cp_beijing"); } 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_ComItem item = UI_ComItem.Proxy(obj); item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg); //item.m_txtCount.SetVar("count", itemData.num.ToString()).FlushVars(); item.m_txtCount.text = itemData.num.ToString(); item.target.data = itemCfg; item.m_QualityType.selectedIndex = itemCfg.rarity - 1; item.m_ShowName.selectedIndex = 1; item.m_txtName.text = itemCfg.name; //是礼包就加入红点 if (((itemCfg.itemType == ConstItemType.USEABLE && itemCfg.subType == ConstItemSubType.USEABLE_GIFT_BAG_SELECTABLE) || (itemCfg.itemType == ConstItemType.USEABLE && itemCfg.subType == ConstItemSubType.USEABLE_GIFT_BAG_RANDOM)) && itemData.id != 6003001 && itemData.id != 6003002) { RedDotController.Instance.SetComRedDot(item.target, true); } else { RedDotController.Instance.SetComRedDot(item.target, false); } UI_ComItem.ProxyEnd(); } 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(itemCfg.id); } else { //暂时程序走不到这里,这里是以前用来使用物品的一个界面---20230607--hxj注释 ViewManager.Show(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); } } }