mergemilitary/Assets/Scripts/UIs/CustomControl/LevelDisplay.cs

31 lines
758 B
C#
Raw Normal View History

2022-05-23 13:39:59 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LevelDisplay : MonoBehaviour
{
[SerializeField] Text mTxtLevel;
[SerializeField] Transform mCtnSpots;
private List<LevelSpot> mSpots;
private void Awake()
{
mSpots = Utils.GetChildListFirstLayer<LevelSpot>(mCtnSpots);
}
public void Init(int pLevel)
{
mTxtLevel.text = string.Format(LanguageConfig.Instance.GetText("Level"), pLevel);
int tCurIndex = pLevel % mSpots.Count - 1;
if (tCurIndex < 0)
tCurIndex += mSpots.Count;
for (int i = 0; i < mSpots.Count; i++)
{
mSpots[i].InitSpot(i < tCurIndex, i == tCurIndex);
}
}
}