Files
ConvenientHorror/Assets/Scripts/Player/ChangeHealth.cs

63 lines
1.2 KiB
C#

using TMPro;
using UnityEngine;
using static UnityEngine.EventSystems.EventTrigger;
public class ChangeHealth : MonoBehaviour
{
[Header("UI and HUD")]
[SerializeField] GameObject panel;
[SerializeField] TMP_Text healthHUD;
[SerializeField] public int standardHealth = 3;
[Header("ScriptPile")]
InventoryScript inventory;
GameOver end;
private void Awake()
{
inventory = panel.GetComponent<InventoryScript>();
end = panel.GetComponent<GameOver>();
}
void Start()
{
inventory.Health = standardHealth;
Debug.Log(inventory.Health);
}
void Update()
{
healthHUD.text = inventory.Health.ToString();
if (inventory.Health <= 0)
{
Die();
}
}
public void GetHit() //MUSS NOCH MIT ENEMIES VERKNÜPFT WERDEN
{
if (inventory.Health > 0)
{
inventory.Health -= 1; //MAGIC NUMBER BITTE BEACHTEN
}
Debug.Log("Ouch, you bastard.");
}
public void Die()
{
//Time.timeScale = 0; //Wieder umlegen
end.recentDeath = true;
end.ShowDeathScreen();
Debug.Log("rest in pizza");
}
}