Problem with enemy AI

Hey guys ! I have been trying to make an simple AI, that goes to player and when its in range, it attacks. All worked well, but then I added more attacks (like kick) and ruined my code :smiley: It changes attacks depending on attNumber. If attnumber is 0 it makes attack 1 and increases attNumber. If attNumber is 1,it makes attack 2 and increase attNumber. Is same while having attNumber 1, but instead of increasing attNumber, it sets it 0 again. But when I play the game it makes all 3 attacks and then it stops. I tried everything but nothing worked. Please help me.

public class Chase : MonoBehaviour {

    public Transform player;
    public Animator anim;

    public Slider healthbar;

    public int attNumber;
    public int attCooldown;
    public int attCooldown2;
    public int attCooldown3;

    // Use this for initialization
    void Start () {

        anim = GetComponent<Animator>();
	}
	
	// Update is called once per frame
	void Update () {

        if (healthbar.value <= 0) return;

        Vector3 direction = player.position - this.transform.position;
        float angle = Vector3.Angle(direction, this.transform.forward);

        //Když je dále než 25 a pod stupněm více než 100
        if (Vector3.Distance(player.position, this.transform.position) < 25 && angle < 180)
        {

            direction.y = 0;

            //Otoč se na něj
            this.transform.rotation = Quaternion.Slerp(this.transform.rotation,
                                      Quaternion.LookRotation(direction), 0.1f);
            //Vypni Idle
            anim.SetBool("isIdle", false);

            //Když je dále než 5, jdi k němu
            if (direction.magnitude > 5)
            {
                this.transform.Translate(0, 0, 0.05f);
                anim.SetBool("isWalking", true);
                anim.SetBool("isAttacking", false);
            }
            
            //Jinak když je blíže než 5 ...
            if(direction.magnitude < 5)
            {
                // ... attNumer je 0 tak použij útok 1, vypni Walk a zvyš attNumber o 1
                if (attNumber == 0)
                {
                    anim.SetBool("isAttacking", true);
                    anim.SetBool("isAttacking2", false);
                    anim.SetBool("isAttacking3", false);
                    anim.SetBool("isWalking", false);
                    StartCoroutine(AttCooldown());
                    attNumber = attNumber + 1;
                }
                else if (attNumber == 1)
                {
                    anim.SetBool("isAttacking2", true);
                    anim.SetBool("isAttacking", false);
                    anim.SetBool("isAttacking3", false);
                    anim.SetBool("isWalking", false);
                    StartCoroutine(AttCooldown());
                    attNumber = attNumber + 1;
                }
                else if (attNumber == 2)
                {
                    anim.SetBool("isAttacking3", true);
                    anim.SetBool("isAttacking", false);
                    anim.SetBool("isAttacking2", false);
                    anim.SetBool("isWalking", false);
                    StartCoroutine(AttCooldown());
                    attNumber = 0;
                }
                else
                {
                    anim.SetBool("isAttacking", false);
                    anim.SetBool("isAttacking2", false);
                    anim.SetBool("isAttacking3", false);
                    attNumber = 0;
                }
            }
        }//Jinak zapni Idle a vypni Walk
        else
        {
            anim.SetBool("isIdle", true);
            anim.SetBool("isWalking", false);
        }
	}

    IEnumerator AttCooldown()
    {
        yield return new WaitForSeconds(attCooldown);
    }
}

Thank you guys ! I hav dne it another way and it seems to work ! Thanks everyone !

attCooldown = 0;

        if (attNumber == 0 && attCooldown <= 0)
        {
            Attack1();

            attCooldown = attCooldownDeposit;
            attCooldown -= Time.deltaTime;

            attNumber += 1;
        }
        else if (attNumber == 1 && attCooldown <= 0)
        {
            Attack2();

            attCooldown = attCooldownDeposit;
            attCooldown -= Time.deltaTime;

            attNumber += 1;
        }
        else if (attNumber == 2 && attCooldown <= 0)
        {
            Attack3();

            attCooldown = attCooldownDeposit;
            attCooldown -= Time.deltaTime;

            attNumber = 0;
        }
        else
        {
            NotAttack();
        }