using Unity.Properties;
using UnityEditor.U2D.Aseprite;
using UnityEngine;
using UnityEngine.U2D;

public class CEShootState : CEBaseState
{
    CEVariables cEVariables;
    public float timer;
    public float timesShoot;

    public override void EnterState(CEStateManager CornerEnemy)
    {
        cEVariables = CornerEnemy.GetComponent<CEVariables>();
        timer = 0;
        timesShoot = 0;
    }

    public override void UpdateState(CEStateManager CornerEnemy)
    {    
        timer += Time.deltaTime;
        if(timer > cEVariables.timeBetweenShots)
        {
            timer = 0;
            Shoot();
            timesShoot++;
        } 

        if(timesShoot > cEVariables.shootAmount)
        {
            CornerEnemy.SwitchState(CornerEnemy.MoveState);
        }
    }



    public void Shoot()
    {
        cEVariables.CreateBullet();
    }
}
