WinScreen

This commit is contained in:
Josiah
2026-01-31 22:48:42 -06:00
parent b091ae3fcd
commit db956e62ef
4 changed files with 208 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
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;
}
}
}