115 lines
2.5 KiB
C#
115 lines
2.5 KiB
C#
using TMPro;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using static UnityEngine.EventSystems.EventTrigger;
|
|
|
|
public class ChangeHealth : MonoBehaviour
|
|
{
|
|
[Header("UI and HUD")]
|
|
|
|
|
|
[SerializeField] public int deathCounter;
|
|
[SerializeField] GameObject scriptPile;
|
|
[SerializeField] GameObject scriptPileAgain;
|
|
[SerializeField] GameObject guessWhatAgain;
|
|
[SerializeField] TMP_Text healthHUD;
|
|
//[SerializeField] GameObject levelScript; //wird aktuell nicht genutzt
|
|
|
|
|
|
[Header("Enemies")]
|
|
[SerializeField] GameObject eFie;
|
|
[SerializeField] GameObject eSilv;
|
|
[SerializeField] GameObject eHai;
|
|
|
|
[Header("ScriptPile")]
|
|
|
|
LevelBehavior level;
|
|
InventoryScript inventory;
|
|
GameOver end;
|
|
|
|
|
|
FieScript fie;
|
|
SilvScript silv;
|
|
HaiScript hai;
|
|
|
|
|
|
private void Awake()
|
|
{
|
|
inventory = scriptPileAgain.GetComponent<InventoryScript>(); //TO DO: FIXEN
|
|
end = guessWhatAgain.GetComponent<GameOver>();
|
|
level = scriptPile.GetComponent<LevelBehavior>();
|
|
|
|
fie = eFie.GetComponent<FieScript>();
|
|
silv = eSilv.GetComponent<SilvScript>();
|
|
hai = eHai.GetComponent<HaiScript>();
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
if (level.gameOngoing == true)
|
|
{
|
|
Debug.Log("ich existiere!");
|
|
}
|
|
|
|
deathCounter = 0;
|
|
inventory.Health = inventory.StandardHealth;
|
|
Debug.Log(inventory.Health);
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
healthHUD.text = inventory.Health.ToString();
|
|
|
|
|
|
}
|
|
|
|
public void GetHit() //MUSS NOCH MIT ENEMIES VERKNÜPFT WERDEN
|
|
{
|
|
|
|
Vibrator.Vibrate();
|
|
if (inventory.Health > 0)
|
|
{
|
|
inventory.Health -= 1; //MAGIC NUMBER BITTE BEACHTEN
|
|
}
|
|
|
|
Debug.Log("Ouch, you bastard.");
|
|
|
|
if (inventory.Health <= 0)
|
|
{
|
|
Die();
|
|
}
|
|
}
|
|
|
|
public void GetHitHard() //MUSS NOCH MIT ENEMIES VERKNÜPFT WERDEN
|
|
{
|
|
Vibrator.Vibrate();
|
|
if (inventory.Health > 0)
|
|
{
|
|
inventory.Health -= 2; //MAGIC NUMBER BITTE BEACHTEN
|
|
}
|
|
|
|
Debug.Log("Ouch, you bastardo.");
|
|
|
|
if (inventory.Health <= 0)
|
|
{
|
|
Die();
|
|
}
|
|
}
|
|
|
|
public void Die()
|
|
{
|
|
deathCounter++;
|
|
Debug.Log(deathCounter);
|
|
end.CalculateCost();
|
|
//Time.timeScale = 0; //Wieder umlegen
|
|
end.ShowDeathScreen();
|
|
Debug.Log("rest in pizza");
|
|
|
|
level.gameOngoing = false;
|
|
|
|
end.StopEnemies();
|
|
}
|
|
|
|
|
|
}
|