using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ZombieAttackState : BaseZombieAIState {

    private float attackRange = 2;

    public override void UpdateState()
    {
        base.UpdateState();

        if (!this.controller.Target.Health.IsAlive)
        {
            this.controller.ChangeState(new ZombiePatrolState());
            return;
        }

        if (Vector3.Distance (this.controller.transform.position, this.controller.Target.transform.position) < attackRange ) {
            this.controller.Zombie.Attacker.Attack();
        } else {
            this.controller.ChangeState(new ZombieChaseState());
        }
    }
}
