using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy : MonoBehaviour
{
    public float currentHealth;
    private float maxHealth;

    [SerializeField] private GameObject healthBar;

    private void Awake()
    {
        healthBar = this.gameObject.transform.GetChild(0).GetChild(0).GetChild(0).gameObject;
    }

    public void SetSize(float sizeNormalized)
    {
        healthBar.transform.localScale = new Vector3(sizeNormalized, 1f);
    }

    public void SetColor(Color color)
    {
        healthBar.GetComponent<SpriteRenderer>().color = color;
    }

    public void TakeDamage(float dmg)
    {
        currentHealth -= dmg;
        SetSize(currentHealth);
    }
}
