private void HostileEnemyAI() { if (isHostile == true) { if (distanceBetween <= attackRadius && state != State.attacking) { StopAllCoroutines(); state = State.attacking; //weaponSystem.AttackTarget(playerObj); weaponSystem.AttackTargetRepeatedly(playerObj); } if (canChase == false && distanceBetween > attackRadius) { state = State.idle; } if (canPatrol == false && canChase == true && distanceBetween > attackRadius && distanceBetween > catchRadius && state != State.idle) { StopAllCoroutines(); print("I should stop chasing"); npcMovement.agent.destination = returningPosition; state = State.idle; } } if (canChase == true && distanceBetween > attackRadius && distanceBetween <= catchRadius && state != State.chasing) { StopAllCoroutines(); state = State.chasing; StartCoroutine(ChasePlayer()); if (isHostile == true) { npcMovement.animatorForwardCap = 1f; npcMovement.agent.speed = npcMovement.currentSpeed; } } }
IEnumerator MoveAndAttackRepeatedly(EnemyAI enemy) { yield return(StartCoroutine(MoveToTarget(enemy.gameObject))); weaponSystem.AttackTargetRepeatedly(enemy.gameObject); }