using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using proto; namespace MoleMole { public class MonoShopStoreTab : MonoBehaviour { private const string ACTIVITY_SHOP_ITEM_BUTTON_PREFAB_PATH = "UI/Menus/Widget/Shop/ActivityItemButton"; private Transform _scrollViewTrans; private int _currentSelectedGoodsID; private StoreDataItem _storeDataItem; private bool _hasPlayAnim; private UIShopType _shopType; public void SetupView(UIShopType shopType, StoreDataItem storeDataItem, Text tabText, bool playAnim = true, bool clearCurrentSelectGoods = true) { _shopType = shopType; if (clearCurrentSelectGoods) { _currentSelectedGoodsID = 0; base.transform.parent.Find("CartInfoPanel/Info").gameObject.SetActive(false); } _scrollViewTrans = base.transform.Find("ScrollView"); _storeDataItem = storeDataItem; SetShopIsOpen(); tabText.text = LocalizationGeneralLogic.GetText(_storeDataItem.shopNameTextID); SetupMetalNum(); SetupAutoRefreshInfo(); SetupManualRefreshInfo(); SetupGoodsItem(playAnim); base.transform.Find("SpecialDesc").gameObject.SetActive(false); } public void OnManualRefresh() { if (_storeDataItem.manualRefreshTimes >= _storeDataItem.maxManualRefreshTimes) { return; } string text = LocalizationGeneralLogic.GetText("Menu_Hcoin"); if (_storeDataItem.refreshItemID == 0) { if (_storeDataItem.nextRefreshCost > Singleton.Instance.playerData.hcoin) { Singleton.Instance.ShowDialog(new GeneralHintDialogContext(LocalizationGeneralLogic.GetText("Menu_ShopManualRefreshLackHCoin", text))); return; } Singleton.Instance.ShowDialog(new GeneralDialogContext { type = GeneralDialogContext.ButtonType.DoubleButton, title = LocalizationGeneralLogic.GetText("Menu_Title_Tips"), desc = LocalizationGeneralLogic.GetText("Menu_Desc_RefreshShopHint", _storeDataItem.nextRefreshCost, text), buttonCallBack = DoRequestToRefresh }); return; } int num = 0; StorageDataItemBase storageDataItemBase = Singleton.Instance.TryGetMaterialDataByID(_storeDataItem.refreshItemID); StorageDataItemBase dummyStorageDataItem = Singleton.Instance.GetDummyStorageDataItem(_storeDataItem.refreshItemID); if (storageDataItemBase != null) { num = storageDataItemBase.number; } if (_storeDataItem.nextRefreshCost > num) { Singleton.Instance.ShowDialog(new GeneralHintDialogContext(LocalizationGeneralLogic.GetText("Menu_ShopManualRefreshLackHCoin", dummyStorageDataItem.GetDisplayTitle()))); return; } Singleton.Instance.ShowDialog(new GeneralDialogContext { type = GeneralDialogContext.ButtonType.DoubleButton, title = LocalizationGeneralLogic.GetText("Menu_Title_Tips"), desc = LocalizationGeneralLogic.GetText("Menu_Desc_RefreshShopHint", _storeDataItem.nextRefreshCost, dummyStorageDataItem.GetDisplayTitle()), buttonCallBack = DoRequestToRefresh }); } public void OnBuyGoods() { if (!CanBuyGoods()) { return; } if (_shopType == UIShopType.SHOP_GACHATICKET) { int ticketID = _currentSelectedGoodsID; int num = 1; if (Singleton.Instance.playerData.gachaTicketPriceDict.ContainsKey(_currentSelectedGoodsID / 10)) { ticketID = _currentSelectedGoodsID / 10; num = 10; } Singleton.Instance.RequestBuyGachaTicket(ticketID, num); } else { Singleton.Instance.RequestBuyGoods(_storeDataItem.shopID, _currentSelectedGoodsID); } } public void OnSelectGoods(Goods goods) { ShopGoodsMetaData shopGoodsMetaData; if (_shopType == UIShopType.SHOP_GACHATICKET) { int goods_id = (int)goods.goods_id; int hCoinCost = Singleton.Instance.playerData.gachaTicketPriceDict[(int)goods.goods_id]; shopGoodsMetaData = new ShopGoodsMetaData((int)goods.goods_id, (int)goods.goods_id, 1, 1, hCoinCost, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, int.MaxValue, 1, 10000, false); if (Singleton.Instance.playerData.gachaTicketPriceDict.ContainsKey(goods_id / 10)) { hCoinCost = Singleton.Instance.playerData.gachaTicketPriceDict[(int)goods.goods_id / 10]; shopGoodsMetaData = new ShopGoodsMetaData(goods_id, goods_id / 10, 1, 10, hCoinCost * 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, int.MaxValue, 1, 10000, false); } } else { shopGoodsMetaData = ShopGoodsMetaDataReader.GetShopGoodsMetaDataByKey((int)goods.goods_id); } if (shopGoodsMetaData == null) { return; } _currentSelectedGoodsID = (int)goods.goods_id; if (_shopType == UIShopType.SHOP_ACTIVITY) { RefreshActivityScroller(); } else { _scrollViewTrans.GetComponent().RefreshCurrent(); } base.transform.parent.Find("CartInfoPanel/Info").gameObject.SetActive(true); StorageDataItemBase dummyStorageDataItem = Singleton.Instance.GetDummyStorageDataItem(shopGoodsMetaData.ItemID, shopGoodsMetaData.ItemLevel); string empty = string.Empty; if (goods.buy_times >= shopGoodsMetaData.MaxBuyTimes) { empty = LocalizationGeneralLogic.GetText("Menu_ShopStoreBuyCostLackMoney"); base.transform.parent.Find("CartInfoPanel/BuyBtn").GetComponent