using UnityEngine;
using UnityEngine.UI;

public class RangeEnemy : Enemy
{
    public GameObject bullet;
    public Transform grab;
    public float attackCooldown = 3f;
    [SerializeField] private float lastAttackTime;

    public override void TargetPlayer()
    {
        agent.isStopped = true;

        if (Time.time - lastAttackTime >= attackCooldown)
        {
            //PARA PRUEBAS RAPIDAS:
            transform.LookAt(player.position);
            Attack();
            //-------------------//
            lastAttackTime = Time.time;
        }
    }

    public void Attack()
    {
        Instantiate(bullet, grab.position, grab.rotation);
    }
}
