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); } }
private void OnMouseOverWalkable(Vector3 destination) { if (Input.GetMouseButtonDown(1) || Input.GetMouseButton(0)) { weponSystem.StopAttacking(); character.SetDestination(destination); } }