void Update() { distanceToPlayer = Vector3.Distance(player.transform.position, transform.position); WeponSystem weponSystem = GetComponent <WeponSystem>(); currentWeponRange = weponSystem.GetCurrentWepon().GetMaxAttackRange(); bool inWeponCircle = distanceToPlayer <= currentWeponRange; bool inChaseCircle = distanceToPlayer > currentWeponRange && distanceToPlayer <= chaseRadius; bool outsideChaseRing = distanceToPlayer > chaseRadius; if (outsideChaseRing) { StopAllCoroutines(); weponSystem.StopAttacking(); StartCoroutine(Patrol()); } if (inChaseCircle) { StopAllCoroutines(); StartCoroutine(ChasePlayer()); } if (inWeponCircle) { StopAllCoroutines(); state = State.attacking; weponSystem.AttackTarget(player.gameObject); } }
void Start() { character = GetComponent <Character>(); abilities = GetComponent <SpecialAbilities>(); audioSource = GetComponent <AudioSource>(); weponSystem = GetComponent <WeponSystem>(); RegisterForMouseEvents(); }