using System.Collections.Generic; using System.Linq; using MoleMole.Config; using UnityEngine; using UnityEngine.UI; namespace MoleMole { public class StorageShowPageContext : BasePageContext { public enum FeatureType { Normal = 0, SelectForSell = 1, SelectForPowerUp = 2 } public const string WEAPON_TAB = "WeaponTab"; public const string STIGMATA_TAB = "StigmataTab"; public const string Item_TAB = "ItemTab"; public const string Fragment_TAB = "FragmentTab"; public static readonly string[] TAB_KEY = new string[4] { "WeaponTab", "StigmataTab", "ItemTab", "FragmentTab" }; public string defaultTab = string.Empty; public FeatureType featureType; public StorageDataItemBase powerUpTarget; public List selectedResources; private TabManager _tabManager; private Dictionary> _tabItemList; private MonoStorageSelectForSellPanel _sellPanel; private MonoStorageSelectForPowerUp _powerUpPanel; private Dictionary _scrollerDict; private Dictionary _fadeManagerDict; private Dictionary> _itemBeforeDict; public StorageShowPageContext() { config = new ContextPattern { contextName = "StorageShowPageContext", viewPrefabPath = "UI/Menus/Page/Storage/StorageShowPage", cacheType = ViewCacheType.AlwaysCached }; _tabManager = new TabManager(); _tabManager.onSetActive += OnTabSetActive; _tabItemList = new Dictionary>(); } public override bool OnNotify(Notify ntf) { if (ntf.type == NotifyTypes.SetSellViewActive) { return OnSetSellViewActive((bool)ntf.body); } if (ntf.type == NotifyTypes.SetStorageSortType) { return OnSetSortType((StorageModule.StorageSortType)(int)ntf.body); } if (ntf.type == NotifyTypes.RefreshStorageShowing) { RefreshShowingTabItem(); } return false; } public override bool OnPacket(NetPacketV1 pkt) { switch (pkt.getCmdId()) { case 27: case 28: SetupView(); break; case 103: SetupFragmentTab(); if (_tabManager.GetShowingTabKey() == "FragmentTab") { GameObject showingTabContent = _tabManager.GetShowingTabContent(); if (_fadeManagerDict.ContainsKey(showingTabContent)) { _fadeManagerDict[showingTabContent].Init(_scrollerDict[showingTabContent].GetItemDict(), null, IsStorageItemDataEqual); _fadeManagerDict[showingTabContent].Play(); _itemBeforeDict[showingTabContent] = null; } } break; case 40: case 136: return SetupView(); } return false; } protected override void BindViewCallbacks() { BindViewCallback(base.view.transform.Find("TabBtns/TabBtn_1").GetComponent