Komplett Lauffähig + Vibration + Boni + Enemie "Jumpscares" - Audio

This commit is contained in:
2026-02-17 21:15:37 +01:00
parent 8b0452b1ed
commit 655e91627a
54 changed files with 8214 additions and 403 deletions

View File

@@ -13,10 +13,14 @@ public class GameOver : MonoBehaviour
private float duration = 4f;
[SerializeField] public float timer;
[SerializeField] TMP_Text deathTime;
[SerializeField] TMP_Text infoText;
[SerializeField] public TMP_Text infoText;
[SerializeField] public TMP_Text GameStateText;
[SerializeField] public GameObject retryButton;
[SerializeField] public GameObject costField;
[SerializeField] TMP_Text costText;
[SerializeField] int cost;
//[SerializeField] public bool recentDeath; //discaraded
[SerializeField] GameObject levelScript;
[SerializeField] public bool timerOn;
@@ -27,12 +31,17 @@ public class GameOver : MonoBehaviour
[SerializeField] GameObject scriptPile;
[SerializeField] GameObject eFie;
[SerializeField] GameObject eSilv;
[SerializeField] GameObject eHai;
InventoryScript inventory;
ChangeHealth healthScript;
HandleEnergy battery;
FieScript fie;
SilvScript silv;
HaiScript hai;
LevelBehavior level;
private void Awake()
{
@@ -40,6 +49,9 @@ public class GameOver : MonoBehaviour
healthScript = scriptPile.GetComponent<ChangeHealth>();
battery = scriptPile.GetComponent<HandleEnergy>();
fie = eFie.GetComponent<FieScript>();
hai = eHai.GetComponent<HaiScript>();
silv = eSilv.GetComponent<SilvScript>();
level = levelScript.GetComponent<LevelBehavior>();
}
void Start()
@@ -51,26 +63,26 @@ public class GameOver : MonoBehaviour
void Update()
{
if (level.gameWon == true)
{
CheckWinTime();
}
else
{
CheckDeathTime();
}
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);
retryButton.SetActive(true);
costField.SetActive(true);
LeanTween.scale(deathPanel, transform.localScale * 1f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce);
SpeakEnemy();
costText.text = cost.ToString(); //ZUM DEBUGGEN
CheckDeathTime();
@@ -78,6 +90,25 @@ public class GameOver : MonoBehaviour
//OPTION INS MAINMENUE ZURÜCKZUKEHREN
}
public void ShowWinScreen()
{
Debug.Log("Gut gemacht");
StopEnemies();
timerOn = true;
timer = 10f;
deathPanel.SetActive(true);
LeanTween.scale(deathPanel, transform.localScale * 1f, duration * Time.deltaTime).setDelay(.1f).setEase(LeanTweenType.easeOutBounce);
CheckWinTime();
GameStateText.text = "You won!";
infoText.text = "You earned " + level.earnedGems + " Gems!";
retryButton.SetActive(false);
costField.SetActive(false);
}
public void GiveNewChance()
{
if (inventory.Gems >= cost)
@@ -97,17 +128,17 @@ public class GameOver : MonoBehaviour
public void StopBothering()
{
Time.timeScale = 1; //UNSICHER OB LADEN VON SCENE DEN WERT AUTO. AUF 1 SETZT
//Time.timeScale = 1; //UNSICHER OB LADEN VON SCENE DEN WERT AUTO. AUF 1 SETZT //ausgebaut
Debug.Log("Jetzt würdest du wieder in die MainMenueScene geschmissen werden");
//SceneManager.LoadSceneAsync(0); //MUSS AM ENDE WIEDER EINGEBAUT WERDEN
SceneManager.LoadSceneAsync(0);
}
public void NewChance()
{
inventory.Health = healthScript.standardHealth;
inventory.Health = inventory.StandardHealth;
if (battery.standardEnergy >= (inventory.Energy + battery.addEnergyValue))
if (inventory.StandardEnergy >= (inventory.Energy + battery.addEnergyValue))
{
inventory.Energy += battery.addEnergyValue;
}
@@ -119,6 +150,10 @@ public class GameOver : MonoBehaviour
//Logik: bei Retry, soll der Player nochmal neue Energie bekommen
fie.StartStuff();
silv.StartStuff();
hai.StartStuff();
level.gameOngoing = true;
}
public void CheckDeathTime()
@@ -140,6 +175,28 @@ public class GameOver : MonoBehaviour
}
}
public void CheckWinTime()
{
if (timerOn == true)
{
timer += zeit - Time.deltaTime;
deathTime.text = Convert.ToInt32(timer).ToString();
if (timer <= 0.0f)
{
timerOn = false;
timer = 10f;
Debug.Log("Next up: SwitchScene()");
level.SwitchScene();
Debug.Log("Just swapped scripts");
}
}
}
public void CalculateCost()
{
cost = healthScript.deathCounter * 100;
@@ -155,9 +212,6 @@ public class GameOver : MonoBehaviour
infoText.text = "But you refused.";
}
}
public bool silvKill;
public bool haiKill;
public void SpeakEnemy()
{
@@ -166,11 +220,11 @@ public class GameOver : MonoBehaviour
infoText.text = "HAAHAHAHAHAAHAHAHAHAHAHAHAHA";
}
if (silvKill)
if (silv.silvKill)
{
infoText.text = "Oh no, I accidently killed someone again. I'm sowy. I just wanted to hug you :(";
}
if (haiKill)
if (hai.haiKill)
{
infoText.text = "You sound great...";
}
@@ -179,4 +233,10 @@ public class GameOver : MonoBehaviour
infoText.text = "Try again?";
}
}
public void StopEnemies()
{
fie.StopAllCoroutines();
silv.StopAllCoroutines();
hai.StopAllCoroutines();
}
}