RangedEnemy.Update C# (CSharp) Method

Update() public method

public Update ( ) : void
return void
    void Update()
    {
        base.Update();

        if (!freeFall)
        {
            if (target != null)
            {
                targetPos = target.transform.position;
                if (!isStunned)
                {
                    if (distL > attackRange && distR > attackRange)
                    {
                        Act(classification);
                    }
                    else
                    {
                        zDiff = targetPos.z - transform.position.z;
                        if (Math.Abs(targetPos.x - transform.position.x) > 0.3)
                        {
                            moveController.OrientFacingLeft((targetPos.x - transform.position.x) < 0, moveController.GetFacing());
                        }
                        if (Math.Abs(zDiff) > 0.25f)
                        {
                            vel = new Vector3(0, 0, zDiff);
                            //Move(new Vector3(0, 0, zDiff), speed);
                        }
                        else
                        {
                            if (attack_CD >= 4)
                                Attack();
                        }
                    }
                }
            }
            else
            {
                if (target.GetComponent<Player>().getDown())
                    target = FindObjectOfType<PlayerManager>().getUpPlayer().gameObject;
                else
                {
                    //player lost
                    //Destroy(gameObject);
                }
            }
            if (stunTimer > 0)
                stunTimer -= Time.deltaTime;
            else
                isStunned = false;

        }

        Move(vel, speed);
        animationController.isAttacking = isAttacking;
        attack_CD += Time.deltaTime;
    }