35 lines
800 B
C#
35 lines
800 B
C#
using Unity.VectorGraphics;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UIElements;
|
|
|
|
public class WinScreenController : MonoBehaviour
|
|
{
|
|
[SerializeField] private int winScore = 100;
|
|
|
|
private string winScreenScene = "Win";
|
|
|
|
private void OnEnable()
|
|
{
|
|
/*var root = GetComponent<UIDocument>().rootVisualElement;
|
|
winScreen = root.Q<VisualElement>("WinScreen");
|
|
|
|
winScreen.style.display = DisplayStyle.None;*/
|
|
|
|
ScoreManager.OnScoreChanged += CheckWinCondition;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
ScoreManager.OnScoreChanged -= CheckWinCondition;
|
|
}
|
|
|
|
private void CheckWinCondition(int score)
|
|
{
|
|
if (score >= winScore)
|
|
{
|
|
SceneManager.LoadScene(winScreenScene);
|
|
}
|
|
}
|
|
}
|