WinScreen
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user