49 lines
1.0 KiB
C#
49 lines
1.0 KiB
C#
using PahlawanEnergi.Quiz;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace PahlawanEnergi
|
|
{
|
|
public class ResultScreen : MonoBehaviour
|
|
{
|
|
[SerializeField] private TextMeshProUGUI statusText;
|
|
[SerializeField] private CanvasGroup[] stars = new CanvasGroup[3];
|
|
[SerializeField] private Button buttonNext;
|
|
|
|
|
|
private void OnEnable()
|
|
{
|
|
Initialize();
|
|
}
|
|
|
|
|
|
private void Initialize()
|
|
{
|
|
int score = QuizManager.instance.Score;
|
|
int level = QuizManager.instance.level;
|
|
statusText.text = score > 1 ? "BERHASIL!" : "GAGAL!";
|
|
|
|
for (int i = 0; i < stars.Length; i++)
|
|
{
|
|
stars[i].alpha = 0.3f;
|
|
}
|
|
|
|
|
|
buttonNext.gameObject.SetActive(level < 5 && score > 1);
|
|
|
|
for (int i = 0; i < score; i++)
|
|
{
|
|
stars[i].alpha = 1f;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|