using JetBrains.Annotations; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; public class LevelBehavior : MonoBehaviour { [SerializeField] GameObject eFie; [SerializeField] GameObject eSilv; [SerializeField] GameObject eHai; [SerializeField] GameObject deathPanel; [SerializeField] GameObject inventoryScript; FieScript fie; SilvScript silv; HaiScript hai; GameOver end; InventoryScript inventory; int curScene = 0; float timer = 0f; public bool gameOngoing; public int earnGems = 5; public int earnedGems = 0; public bool gameWon; private void Awake() { fie = eFie.GetComponent(); silv = eSilv.GetComponent(); hai = eHai.GetComponent(); end = inventoryScript.GetComponent(); inventory = inventoryScript.GetComponent(); } void Start() { gameWon = false; gameOngoing = true; // Create a temporary reference to the current scene. Scene currentScene = SceneManager.GetActiveScene(); // Retrieve the name of this scene. string sceneName = currentScene.name; // Retrieve the index of the scene in the project's build settings. int buildIndex = currentScene.buildIndex; if (sceneName == "Day1") { Debug.Log("Es ist Tag 1"); curScene = 2; fie.stateTime = 7; silv.stateTime = 25; hai.stateTime = 35; } if (sceneName == "Day2") { Debug.Log("Es ist Tag 2"); curScene = 5; fie.stateTime = 5; silv.stateTime = 10; hai.stateTime = 25; // Do something... } else if (sceneName == "Day3") { Debug.Log("Es ist Tag 3"); curScene = 4; fie.stateTime = 3; silv.stateTime = 10; hai.stateTime = 15; // Do something... } } void Update() { if (gameOngoing == true) { TimeIs(); } } public void TimeIs() { timer += Time.deltaTime; //Debug.Log(timer); if (timer >= 90) { end.ShowWinScreen(); gameWon = true; inventory.Gems += earnedGems; timer = 0; gameOngoing = false; } } public void SwitchScene() { Debug.Log("Ich will jetzt in Scene " + curScene++ + " wechseln."); gameOngoing = false; gameWon = false; if (curScene < 5) { Debug.Log("Ist noch nicht Tag 3"); SceneManager.LoadSceneAsync(curScene++); } else { Debug.Log("Es war Tag 3"); SceneManager.LoadScene(1); } } }