chicken_dy/Assets/Scripts/UI/CustomControl/LevelList/LevelPage.cs

48 lines
1.2 KiB
C#
Raw Normal View History

2022-02-13 09:36:12 +00:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LevelPage : PageView
{
public Action<int> DelClickLevel;
public override int Count
{
get
{
2022-02-13 09:50:39 +00:00
int tTotalCount = GameConfig.Instance.LevelSort.Count + 1;//add coming soon
2022-02-13 10:18:17 +00:00
int tUnlockedCount = 23;// PlayerData.Instance.UnlockedLevel;
2022-02-13 09:50:39 +00:00
int tEnoughCount = (tUnlockedCount / CountPerPage + 1) + (tUnlockedCount % CountPerPage == 0 ? -1 : 0);
return Mathf.Min(tTotalCount, tEnoughCount * CountPerPage);
2022-02-13 09:36:12 +00:00
}
}
protected override void ConfigCell(GameObject pCellGob, int pIndex)
{
LevelCell tCell = pCellGob.GetComponent<LevelCell>();
if (pIndex < PlayerData.Instance.UnlockedLevel)
{
tCell.Init(pIndex);
tCell.DelClick = OnClickLevel;
}
else
{
2022-02-13 09:50:39 +00:00
if (pIndex < GameConfig.Instance.LevelSort.Count)
2022-02-13 09:36:12 +00:00
{
tCell.SetEmpty();
}
else
{
tCell.SetComingSoon();
}
}
}
private void OnClickLevel(int pLevelIndex)
{
DelClickLevel?.Invoke(pLevelIndex);
}
}