Ejemplo n.º 1
0
    protected override bool CanAttack()
    {
        Enemy enemy = EnemyInRangeChecker.GetClosestEnemyInRange();

        if (enemy == null)
        {
            return(false);
        }
        Targets.Add(enemy);
        return(true);
    }
    void Update()
    {
        AttackTimer += Time.deltaTime;

        Enemy closest = EnemyInRangeChecker.GetClosestEnemyInRange();

        if (closest != null && rotateToTarget)
        {
            RotateToTarget(closest.gameObject.transform.position);
        }

        if (AttackTimer > delayBetweenAttacks)
        {
            if (!CanAttack())
            {
                return;
            }

            Attack();
            AttackTimer = 0;
        }
    }