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] TMP_Text costText; [SerializeField] int cost; //[SerializeField] public bool recentDeath; //discaraded [SerializeField] public bool timerOn; public float etwas; public float zeit; [Header("ScriptPile")] [SerializeField] GameObject scriptPile; [SerializeField] GameObject eFie; InventoryScript inventory; ChangeHealth healthScript; HandleEnergy battery; FieScript fie; private void Awake() { inventory = scriptPile.GetComponent(); healthScript = scriptPile.GetComponent(); battery = scriptPile.GetComponent(); fie = eFie.GetComponent(); } void Start() { timer = 10f; inventory.Gems = 599; deathPanel.SetActive(false); } void Update() { CheckDeathTime(); //if (Time.timeScale == 1) //{ // Debug.Log("The game is running."); //} //else if(Time.timeScale == 0) //{ // Debug.Log("The game should be paused now."); //} } public void ShowDeathScreen() { fie.StopAllCoroutines(); //Time.timeScale = 0; timerOn = true; timer = 10f; deathPanel.SetActive(true); LeanTween.scale(deathPanel, transform.localScale * 0.5f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce); SpeakEnemy(); costText.text = cost.ToString(); //ZUM DEBUGGEN CheckDeathTime(); //OPTION INS MAINMENUE ZURÜCKZUKEHREN } public void GiveNewChance() { if (inventory.Gems >= cost) { NewChance(); inventory.Gems -= cost; Debug.Log(inventory.Gems); timerOn = false; timer = 10f; } else //EINBAUEN, DASS MAN DORT GEMS KAUFEN KANN { infoText.text = "You don´t have enough gems to do that."; } } public void StopBothering() { 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; } LeanTween.scale(deathPanel, transform.localScale * 0f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce); deathPanel.SetActive(false); //Time.timeScale = 1; //Logik: bei Retry, soll der Player nochmal neue Energie bekommen fie.StartStuff(); } public void CheckDeathTime() { if(timerOn == true) { timer += zeit - Time.deltaTime; deathTime.text = Convert.ToInt32(timer).ToString(); if (timer <= 0.0f) { StopBothering(); timerOn = false; timer = 10f; } } } public void CalculateCost() { cost = healthScript.deathCounter * 100; if (cost == 300) { infoText.text = "You must really like being here."; } if (cost >= 1000) { cost = 900; infoText.text = "But you refused."; } } public bool silvKill; public bool haiKill; public void SpeakEnemy() { if (fie.fieKill) { infoText.text = "HAAHAHAHAHAAHAHAHAHAHAHAHAHA"; } if (silvKill) { infoText.text = "Oh no, I accidently killed someone again. I'm sowy. I just wanted to hug you :("; } if (haiKill) { infoText.text = "You sound great..."; } else { infoText.text = "Try again?"; } } }