using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace MoleMole { public class MonoShopRechargeTab : MonoBehaviour { private Transform _scrollViewTrans; private string _currentSelectedProductID = string.Empty; private List _rechargeDataItemList; private bool _waitRefreshAfterSetupView; private bool _hasPlayAnim; public void SetupView() { _currentSelectedProductID = string.Empty; _scrollViewTrans = base.transform.Find("ScrollView"); _scrollViewTrans.gameObject.SetActive(false); Singleton.Instance.manager.ShowAllProducts(); _waitRefreshAfterSetupView = true; } public void OnRefreshRechargeTab() { _rechargeDataItemList = Singleton.Instance.manager.GetRechargeItemList(); foreach (RechargeDataItem rechargeDataItem in _rechargeDataItemList) { } _currentSelectedProductID = string.Empty; _scrollViewTrans.GetComponent().Init(OnScrollChange, _rechargeDataItemList.Count, new Vector2(0f, 1f)); _scrollViewTrans.gameObject.SetActive(true); if (_waitRefreshAfterSetupView && !_hasPlayAnim) { base.transform.Find("ScrollView/Content").GetComponent().Play("RechargeItemsFadeIn"); _waitRefreshAfterSetupView = false; _hasPlayAnim = true; } } public void OnPucharseProduct() { if (Singleton.Instance.DispatchSeverData.forbidRecharge) { Singleton.Instance.ShowDialog(new GeneralHintDialogContext(LocalizationGeneralLogic.GetText("Menu_ForbidRecharge"))); return; } if (Singleton.Instance.DispatchSeverData.rechargeMaxLimit > 0 && Singleton.Instance.totalPayHCoin >= Singleton.Instance.DispatchSeverData.rechargeMaxLimit) { Singleton.Instance.ShowDialog(new GeneralHintDialogContext(LocalizationGeneralLogic.GetText("Menu_ShopRechargeHCoinLimit"))); return; } if (string.IsNullOrEmpty(_currentSelectedProductID)) { Singleton.Instance.ShowDialog(new GeneralHintDialogContext(LocalizationGeneralLogic.GetText("Menu_ShopNoSelect"))); return; } RechargeDataItem storeItemByProductID = Singleton.Instance.manager.GetStoreItemByProductID(_currentSelectedProductID); if (storeItemByProductID != null) { if (!storeItemByProductID.CanPurchase()) { Singleton.Instance.ShowDialog(new GeneralHintDialogContext(LocalizationGeneralLogic.GetText("IAPTPurchaseLimit"))); } else { Singleton.Instance.manager.Pay(_currentSelectedProductID, storeItemByProductID.productName, (float)storeItemByProductID.serverPrice / 100f); } } else { _currentSelectedProductID = string.Empty; } } public void OnSelectProduct(string productID) { _currentSelectedProductID = productID; _scrollViewTrans.GetComponent().RefreshCurrent(); RechargeDataItem storeItemByProductID = Singleton.Instance.manager.GetStoreItemByProductID(productID); if (storeItemByProductID != null) { base.transform.parent.Find("CartInfoPanel/BuyBtn").GetComponent