using System; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UIElements; using static UnityEngine.Rendering.DebugUI; public class GameOver : MonoBehaviour { [Header("UI and HUB")] [SerializeField] GameObject deathPanel; private float duration = 4f; [SerializeField] public float timer; [SerializeField] TMP_Text deathTime; [SerializeField] TMP_Text infoText; [SerializeField] public bool recentDeath; bool timerOn = false; public float etwas; public float zeit; [Header("ScriptPile")] [SerializeField] GameObject scriptPile; InventoryScript inventory; ChangeHealth healthScript; HandleEnergy battery; private void Awake() { inventory = scriptPile.GetComponent(); healthScript = scriptPile.GetComponent(); battery = scriptPile.GetComponent(); } void Start() { recentDeath = false; //Eigentlicher Wert deathPanel.SetActive(false); recentDeath = true; //ZUM TESTEN timer = 0; } void Update() { recentDeath = true; if (recentDeath) { ShowDeathScreen(); CheckDeathTime(); timerOn = true; } } public void ShowDeathScreen() { deathPanel.SetActive(true); infoText.text = "Try again?"; infoText.text = inventory.Gems.ToString(); //ZUM DEBUGGEN //OPTION INS MAINMENUE ZURÜCKZUKEHREN } public void GiveNewChance() { if (inventory.Gems > 100) { NewChance(); inventory.Gems -= 100; } else //EINBAUEN, DASS MAN DORT GEMS KAUFEN KANN { infoText.text = "You don´t have enough gems to do that."; } } public void StopBothering() { recentDeath = false; Time.timeScale = 1; //UNSICHER OB LADEN VON SCENE DEN WERT AUTO. AUF 1 SETZT Debug.Log("Jetzt würdest du wieder in die MainMenueScene geschmissen werden"); //SceneManager.LoadSceneAsync(0); //MUSS AM ENDE WIEDER EINGEBAUT WERDEN } public void NewChance() { inventory.Health = healthScript.standardHealth; if (battery.standardEnergy >= (inventory.Energy + battery.addEnergyValue)) { inventory.Energy += battery.addEnergyValue; } //Logik: bei Retry, soll der Player nochmal neue Energie bekommen } public void CheckDeathTime() { if(timerOn == true) { timer = 10; zeit -= Time.deltaTime; deathTime.text = Convert.ToInt32(zeit + timer).ToString(); if (zeit >= timer) { recentDeath = false; StopBothering(); timerOn = false; } } } }