52 lines
1.0 KiB
C#
52 lines
1.0 KiB
C#
using System.Threading;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class HandleEnergy : MonoBehaviour
|
|
{
|
|
[Header("Values")]
|
|
|
|
[SerializeField] public int addEnergyValue = 4;
|
|
|
|
[Header("UI and HUD")]
|
|
|
|
|
|
[SerializeField] TMP_Text energyHUD;
|
|
|
|
[Header("ScriptPile")]
|
|
|
|
[SerializeField] GameObject scriptPile;
|
|
|
|
InventoryScript inventory;
|
|
GameOver end;
|
|
|
|
private void Awake()
|
|
{
|
|
inventory = scriptPile.GetComponent<InventoryScript>();
|
|
end = scriptPile.GetComponent<GameOver>(); //UNNÖTIG, BEI ENEGRY 0 IST JA KEIN GAMEOVER
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
inventory.Energy = inventory.StandardEnergy;
|
|
Debug.Log(inventory.Energy);
|
|
}
|
|
|
|
|
|
void Update()
|
|
{
|
|
energyHUD.text = inventory.Energy.ToString();
|
|
}
|
|
|
|
public void LoseEnergy()
|
|
{
|
|
if (inventory.Energy > 0)
|
|
inventory.Energy -= 1; //MAGIC NUMBER BEACHTEN ERSTMAL AUSPROBIEREN
|
|
else
|
|
{
|
|
Debug.Log("Alle alle.");
|
|
}
|
|
|
|
}
|
|
}
|