逻辑bug

This commit is contained in:
yangjing 2022-02-14 12:44:49 +08:00
parent 31f7d6f4bd
commit fea27cdfd4
3 changed files with 41 additions and 6 deletions

View File

@ -12,7 +12,7 @@ public class LevelPage : PageView
get get
{ {
int tTotalCount = GameConfig.Instance.LevelSort.Count + 1;//add coming soon int tTotalCount = GameConfig.Instance.LevelSort.Count + 1;//add coming soon
int tUnlockedCount = 23;// PlayerData.Instance.UnlockedLevel; int tUnlockedCount = PlayerData.Instance.UnlockedLevel;
int tEnoughCount = (tUnlockedCount / CountPerPage + 1) + (tUnlockedCount % CountPerPage == 0 ? -1 : 0); int tEnoughCount = (tUnlockedCount / CountPerPage + 1) + (tUnlockedCount % CountPerPage == 0 ? -1 : 0);
return Mathf.Min(tTotalCount, tEnoughCount * CountPerPage); return Mathf.Min(tTotalCount, tEnoughCount * CountPerPage);

View File

@ -8,6 +8,9 @@ public class PageSpot : MonoBehaviour
private Transform mCtn; private Transform mCtn;
private List<GameObject> mLightSpots; private List<GameObject> mLightSpots;
private List<GameObject> mSpotList;
private int mSpotCount;
private void Awake() private void Awake()
{ {
@ -16,16 +19,16 @@ public class PageSpot : MonoBehaviour
public void Init(int pTotalCount) public void Init(int pTotalCount)
{ {
mSpotCount = pTotalCount;
mLightSpots = new List<GameObject>(); mLightSpots = new List<GameObject>();
for (int i = 0; i < pTotalCount; i++) for (int i = 0; i < pTotalCount; i++)
{ {
GameObject tSpot = Instantiate(mTplSpot, mCtn); GameObject tSpot = GetSpot(i);
tSpot.SetActive(true);
tSpot.transform.localScale = Vector3.one;
mLightSpots.Add(tSpot.transform.GetChild(0).gameObject); mLightSpots.Add(tSpot.transform.GetChild(0).gameObject);
} }
HideUnused();
} }
public void SetPageIndex(int pCurrentIndex) public void SetPageIndex(int pCurrentIndex)
@ -35,4 +38,36 @@ public class PageSpot : MonoBehaviour
mLightSpots[i].SetActive(pCurrentIndex == i); mLightSpots[i].SetActive(pCurrentIndex == i);
} }
} }
private GameObject GetSpot(int pSpotIndex)
{
if (mSpotList == null)
{
mSpotList = new List<GameObject>();
}
GameObject tCell = null;
if (pSpotIndex < mSpotList.Count)
{
tCell = mSpotList[pSpotIndex];
}
else
{
tCell = Instantiate(mTplSpot, mCtn);
tCell.transform.localScale = Vector3.one;
mSpotList.Add(tCell);
}
tCell.SetActive(true);
return tCell;
}
private void HideUnused()
{
for (int i = mSpotCount; i < mSpotList.Count; i++)
{
mSpotList[i].SetActive(false);
}
}
} }

View File

@ -145,7 +145,7 @@ public class PanelMain : BasePanel
private void InitLevelIcons() private void InitLevelIcons()
{ {
mTotalLevel = GameConfig.Instance.LevelSort.Count; mTotalLevel = PlayerData.Instance.UnlockedLevel;
int tLevel = 0; int tLevel = 0;
for (int i = 0; i < mImgLevelIcons.Length; i++) for (int i = 0; i < mImgLevelIcons.Length; i++)