34 lines
786 B
C#
34 lines
786 B
C#
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
|
|
public class WinScreenController : MonoBehaviour
|
|
{
|
|
[SerializeField] private int winScore = 100;
|
|
|
|
private VisualElement winScreen; // ✅ DECLARED HERE
|
|
|
|
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)
|
|
{
|
|
winScreen.style.display = DisplayStyle.Flex;
|
|
Time.timeScale = 0f;
|
|
}
|
|
}
|
|
}
|