using System.Threading;
using TMPro;
using UnityEngine;

public class HandleEnergy : MonoBehaviour
{
    [Header("Values")]

    [SerializeField] public int standardEnergy = 10;
    [SerializeField] public int addEnergyValue = 2;

    [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 = 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.");
        }

    }
}
