using ScrambleKit.Hits;
using UnityEngine;

public class EnemyAnimateHit : MonoBehaviour 
{
    private bool handling = false;
    private float idleAt;

    void TakeHit(HitInfo hit)
    {
        handling = true;
        idleAt = Time.time + hit.StunTime;
        transform.BroadcastMessage("ChangeAnimationState", EnemyState.Hurt);
    }

    void Update()
    {
        if(handling && Time.time >= idleAt)
        {
            handling = false;
            transform.BroadcastMessage("ChangeAnimationState", EnemyState.Idle);
        }
    }
}
