mergemilitary/Assets/Scripts/UIs/PanelShop.cs

60 lines
1.5 KiB
C#
Raw Permalink Normal View History

2022-07-04 11:17:39 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PanelShop : BasePanel
{
[SerializeField] Button mBtnClose;
[SerializeField] Transform mCtnTabs;
[SerializeField] List<IListView> mLists;
private List<TabButton> mTabs;
private int mCurIndex = -1;
private void Awake()
{
UIUtils.BindBtn(mBtnClose, Close);
mTabs = Utils.GetChildListFirstLayer<TabButton>(mCtnTabs);
for (int i = 0; i < mTabs.Count; i++)
{
mTabs[i].DelClick = OnClickTab;
}
}
public override void OnOpen()
{
base.OnOpen();
mTabs[0].gameObject.SetActive(GameConfig.Instance.UseDiamond);
2022-09-09 14:35:49 +00:00
mTabs[1].gameObject.SetActive(TKGSDKManager.Instance.GetConfigBool(TKGParamKey.UsePet));
mTabs[2].gameObject.SetActive(TKGSDKManager.Instance.GetConfigBool(TKGParamKey.UseBoard));
2022-07-04 11:17:39 +00:00
if (mCurIndex < 0)
{
2022-09-09 14:35:49 +00:00
int tInitIndex = 0;
if (!GameConfig.Instance.UseDiamond)
{
tInitIndex = TKGSDKManager.Instance.GetConfigBool(TKGParamKey.UsePet) ? 1 : 2;
}
OnClickTab(tInitIndex);
2022-07-04 11:17:39 +00:00
}
}
private void OnClickTab(int pIndex)
{
mCurIndex = pIndex;
for (int i = 0; i < mTabs.Count; i++)
{
mTabs[i].SetOn(i == mCurIndex);
mLists[i].Show(i == mCurIndex);
if (i == mCurIndex)
{
mLists[i].LoadData();
}
}
}
}