51 lines
1.2 KiB
C#
51 lines
1.2 KiB
C#
using DG.Tweening;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace PahlawanEnergi.MainMenu
|
|
{
|
|
public class LevelSlot : MonoBehaviour
|
|
{
|
|
[SerializeField] private TextMeshProUGUI levelText;
|
|
[SerializeField] private Image[] stars = new Image[3];
|
|
|
|
[SerializeField] private Button button_play;
|
|
[SerializeField] private GameObject lockSign;
|
|
|
|
private LevelSelectScreen levelSelectScreen;
|
|
private LevelProgress progress;
|
|
|
|
private void Awake()
|
|
{
|
|
levelSelectScreen = FindAnyObjectByType<LevelSelectScreen>();
|
|
}
|
|
|
|
public void Setup(LevelProgress progress)
|
|
{
|
|
this.progress = progress;
|
|
levelText.text = $"{progress.level}";
|
|
button_play.gameObject.SetActive(progress.isUnlocked);
|
|
lockSign.gameObject.SetActive(!progress.isUnlocked);
|
|
|
|
|
|
for (int i = 0; i < stars.Length; i++)
|
|
{
|
|
stars[i].DOFade(i < progress.score ? 1 : 0, 0);
|
|
}
|
|
}
|
|
|
|
public void Interact()
|
|
{
|
|
if (!progress.isUnlocked) return;
|
|
|
|
levelSelectScreen.SelectLevel(progress.level);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|