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

public class Hurtable : MonoBehaviour
{
    public int Life;

    public KnockedOutState KnockedOutState;
    public DeadState DeadState;
    public DodgingState DodgingState;
    public IdleState IdleState;
    public RunningState RunningState;

    public Image HealtImage;
    public Sprite[] HealtSprites;
    private int healtIndex;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    public void Hurt(int damage)
    {
        if(IdleState.enabled)
            IdleState.enabled = false;
        if(RunningState.enabled)
            RunningState.enabled = false;
        if(DodgingState.enabled)
            DodgingState.enabled = false;

        Life -= damage;

        healtIndex ++;
        HealtImage.sprite = HealtSprites[healtIndex];

        if(Life <= 0)
        {
            DeadState.enabled = true;
        }
        else
        {
            KnockedOutState.Duration = 2;
            KnockedOutState.enabled = true;
        }
            

        
    }
}
