using UnityEngine;
using UnityEngine.UI;

/// <summary>
/// Link zum OG Script: https://www.youtube.com/watch?v=vNL4WYgvwd8
/// </summary>
public class Health : MonoBehaviour
{
    public int maxHealth = 5;
    public int currentHealth = 5;
    public Image healthbar;

    // health logic
    void Start()
    {
        currentHealth = maxHealth;
    }

    // take dmg logic
    private void Update()
    {
        TakeDamage();
    }
    
    void TakeDamage()
    {
        // code from Christian
        healthbar.fillAmount = (float)currentHealth / (float)maxHealth;

        if (currentHealth <= 0)
        {
            // player is dead
            // death animation
            // game over screen
        }
    }
}
