// Update is called once per frame
    void Update()
    {
        if (GameManagerScript.G.GetPause())
        {
            return;
        }
        if (!myEnemy.GetStunned() && myEnemy.GetInRange() && canAttack && !myEnemy.GetDieing())
        {
            myEnemy.Attack(ranged);
            canAttack = false;
        }


        if (!canAttack)
        {
            if (time <= 0)
            {
                myEnemy.AttackEnd();
                canAttack = true;
                animEnded = false;
                time      = timeR;
            }

            if (time <= timeR - myEnemy.GetAttackTime() && !animEnded)
            {
                myEnemy.AttackEnd();
                if (ranged)
                {
                    myEnemy.ProduceProjectile();
                }

                animEnded = true;
            }

            time -= Time.deltaTime;
        }
    }