GameOver Overlay ist komplett fertig und funktional, später ggf. noch änderungen an info.Text

This commit is contained in:
2026-02-16 15:30:57 +01:00
parent a7aac28d92
commit 1a775172fd
7 changed files with 2826 additions and 47 deletions

View File

@@ -14,9 +14,11 @@ public class GameOver : MonoBehaviour
[SerializeField] public float timer;
[SerializeField] TMP_Text deathTime;
[SerializeField] TMP_Text infoText;
[SerializeField] public bool recentDeath;
[SerializeField] TMP_Text costText;
[SerializeField] int cost;
//[SerializeField] public bool recentDeath; //discaraded
bool timerOn = false;
[SerializeField] public bool timerOn;
public float etwas;
public float zeit;
@@ -39,39 +41,47 @@ public class GameOver : MonoBehaviour
void Start()
{
recentDeath = false; //Eigentlicher Wert
timer = 10f;
inventory.Gems = 599;
deathPanel.SetActive(false);
recentDeath = true; //ZUM TESTEN
timer = 0;
}
void Update()
{
recentDeath = true;
if (recentDeath)
{
ShowDeathScreen();
CheckDeathTime();
timerOn = true;
}
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()
{
//Time.timeScale = 0;
timerOn = true;
timer = 10f;
deathPanel.SetActive(true);
infoText.text = "Try again?";
infoText.text = inventory.Gems.ToString(); //ZUM DEBUGGEN
costText.text = cost.ToString(); //ZUM DEBUGGEN
CheckDeathTime();
//OPTION INS MAINMENUE ZURÜCKZUKEHREN
}
public void GiveNewChance()
{
if (inventory.Gems > 100)
if (inventory.Gems >= cost)
{
NewChance();
inventory.Gems -= 100;
inventory.Gems -= cost;
Debug.Log(inventory.Gems);
timerOn = false;
timer = 10f;
}
else //EINBAUEN, DASS MAN DORT GEMS KAUFEN KANN
@@ -82,7 +92,6 @@ public class GameOver : MonoBehaviour
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
@@ -98,6 +107,9 @@ public class GameOver : MonoBehaviour
inventory.Energy += battery.addEnergyValue;
}
deathPanel.SetActive(false);
//Time.timeScale = 1;
//Logik: bei Retry, soll der Player nochmal neue Energie bekommen
}
@@ -106,20 +118,23 @@ public class GameOver : MonoBehaviour
{
if(timerOn == true)
{
timer = 10;
zeit -= Time.deltaTime;
timer += zeit - Time.deltaTime;
deathTime.text = Convert.ToInt32(zeit + timer).ToString();
deathTime.text = Convert.ToInt32(timer).ToString();
if (zeit >= timer)
if (timer <= 0.0f)
{
recentDeath = false;
StopBothering();
timerOn = false;
timer = 10f;
}
}
}
public void CalculateCost()
{
cost = healthScript.deathCounter * 100;
}
}