We Win
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
using Unity.VectorGraphics;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public class WinScreenController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private int winScore = 100;
|
||||
|
||||
private VisualElement winScreen; // ✅ DECLARED HERE
|
||||
private string winScreenScene = "Win"; // ✅ DECLARED HERE
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
var root = GetComponent<UIDocument>().rootVisualElement;
|
||||
/*var root = GetComponent<UIDocument>().rootVisualElement;
|
||||
winScreen = root.Q<VisualElement>("WinScreen");
|
||||
|
||||
winScreen.style.display = DisplayStyle.None;
|
||||
winScreen.style.display = DisplayStyle.None;*/
|
||||
|
||||
ScoreManager.OnScoreChanged += CheckWinCondition;
|
||||
}
|
||||
@@ -26,8 +28,7 @@ public class WinScreenController : MonoBehaviour
|
||||
{
|
||||
if (score >= winScore)
|
||||
{
|
||||
winScreen.style.display = DisplayStyle.Flex;
|
||||
Time.timeScale = 0f;
|
||||
SceneManager.LoadScene(winScreenScene);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user