Timer eingebaut, Inventory Script überarbeitet, InventoryScript dank Hr. Neuhaus durch Speicherfunktion erweiter, GameOver und GameOverlay ready and working

This commit is contained in:
2026-02-12 08:04:01 +01:00
parent 57f6aa02c8
commit a7aac28d92
5 changed files with 759 additions and 60 deletions

View File

@@ -11,9 +11,15 @@ public class GameOver : MonoBehaviour
[SerializeField] GameObject deathPanel;
private float duration = 4f;
[SerializeField] float timer;
[SerializeField] public float timer;
[SerializeField] TMP_Text deathTime;
[SerializeField] bool recentDeath;
[SerializeField] TMP_Text infoText;
[SerializeField] public bool recentDeath;
bool timerOn = false;
public float etwas;
public float zeit;
[Header("ScriptPile")]
@@ -33,39 +39,53 @@ public class GameOver : MonoBehaviour
void Start()
{
recentDeath = false; //Eigentlicher Wert
deathPanel.SetActive(false);
recentDeath = true;
timer = 10;
recentDeath = true; //ZUM TESTEN
timer = 0;
}
void Update()
{
recentDeath = true;
if (recentDeath)
{
deathTime.text = Convert.ToInt32(timer -= Time.deltaTime).ToString();
if(timer >= 0)
{
StopBothering();
}
}
else
{
StopBothering();
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
SceneManager.LoadSceneAsync(0);
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
}
@@ -73,10 +93,33 @@ public class GameOver : MonoBehaviour
{
inventory.Health = healthScript.standardHealth;
if (battery.standardEnergy <= (inventory.Energy + battery.addEnergyValue))
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;
}
}
}
}