private void Update() { distanceToPlayer = Vector3.Distance(player.transform.position, transform.position); WeaponSystem weaponSystem = GetComponent <WeaponSystem>(); currentWeaponRange = weaponSystem.GetCurrentWeaponInUse().GetMaxAttackRange(); bool inWeaponCircle = distanceToPlayer <= currentWeaponRange; bool inChaseCircle = distanceToPlayer > currentWeaponRange && distanceToPlayer <= chaseRadius; bool outsideChaseRing = distanceToPlayer > chaseRadius; if (outsideChaseRing && state != State.patrolling) { StopAllCoroutines(); weaponSystem.StopAttacking(); StartCoroutine(Patrol()); } if (inChaseCircle && state != State.chasing) { StopAllCoroutines(); weaponSystem.StopAttacking(); StartCoroutine(ChasePlayer()); } if (inWeaponCircle && state != State.attacking) { StopAllCoroutines(); weaponSystem.AttackTarget(player.gameObject); } }
void OnMouseOverPotentiallyWalkable(Vector3 destination) { if (Input.GetMouseButton(0)) { weaponSystem.StopAttacking(); character.SetDestination(destination); } }