GameOver Overlay ist komplett fertig und funktional, später ggf. noch änderungen an info.Text
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ public class ChangeHealth : MonoBehaviour
|
||||
{
|
||||
[Header("UI and HUD")]
|
||||
|
||||
|
||||
[SerializeField] public int deathCounter;
|
||||
[SerializeField] GameObject panel;
|
||||
[SerializeField] TMP_Text healthHUD;
|
||||
[SerializeField] public int standardHealth = 3;
|
||||
@@ -24,6 +26,7 @@ public class ChangeHealth : MonoBehaviour
|
||||
|
||||
void Start()
|
||||
{
|
||||
deathCounter = 0;
|
||||
inventory.Health = standardHealth;
|
||||
Debug.Log(inventory.Health);
|
||||
}
|
||||
@@ -32,10 +35,7 @@ public class ChangeHealth : MonoBehaviour
|
||||
{
|
||||
healthHUD.text = inventory.Health.ToString();
|
||||
|
||||
if (inventory.Health <= 0)
|
||||
{
|
||||
Die();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void GetHit() //MUSS NOCH MIT ENEMIES VERKNÜPFT WERDEN
|
||||
@@ -47,15 +47,23 @@ public class ChangeHealth : MonoBehaviour
|
||||
|
||||
Debug.Log("Ouch, you bastard.");
|
||||
|
||||
if (inventory.Health <= 0)
|
||||
{
|
||||
Die();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void Die()
|
||||
{
|
||||
deathCounter++;
|
||||
Debug.Log(deathCounter);
|
||||
end.CalculateCost();
|
||||
//Time.timeScale = 0; //Wieder umlegen
|
||||
end.recentDeath = true;
|
||||
end.ShowDeathScreen();
|
||||
Debug.Log("rest in pizza");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,10 @@ using UnityEngine;
|
||||
|
||||
public class InventoryData
|
||||
{
|
||||
|
||||
//vielleicht standardHealth, standardEnergy einbauen
|
||||
|
||||
|
||||
// energy
|
||||
public int energy;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user