You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/LevelButton.cs

53 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public enum LevelState { Locked,Completed,Upcoming}
public class LevelButton : MonoBehaviour
{
public LevelState levelState;
public List<GameObject> levelStateImages;
bool[] buttonState = { false, true, true };
public Button button;
public int id;
//private void OnValidate()
//{
// Func();
//}
//public void Func()
//{
// if(id==0)
// id = transform.GetSiblingIndex();
//}
private void Start()
{
CheckState();
StateEnabler();
}
public void CheckState()
{
if (DataManager.Instance.MAXLEVELINDEX < id)
{
levelState = LevelState.Locked;
}
else if (DataManager.Instance.MAXLEVELINDEX == id)
{
levelState = LevelState.Upcoming;
}
else
{
levelState = LevelState.Completed;
}
}
public void StateEnabler()
{
levelStateImages[(int)levelState].SetActive(true);
button.enabled = buttonState[(int)levelState];
}
public void currentLevelIndexSet()
{
DataManager.Instance.CURRENTLEVELINDEX = id;
}
}