コード例 #1
0
    private IEnumerator StartAttack()
    {
        hasAction          = true;
        navAgent.isStopped = true;
        anim.SetBool("Walking", false);

        anim.SetTrigger("Attack");

        yield return(new WaitForSeconds(2));

        if (disabledMovement)
        {
            yield break;
        }

        if (CharUtil.IsTargetWithinRange(transform, playerTransform.position, attackRange))
        {
            playerTransform.GetComponent <HealthManager>().TakeDamage(10f);
        }

        yield return(new WaitForSeconds(2));

        if (disabledMovement)
        {
            yield break;
        }

        anim.SetBool("Walking", true);
        navAgent.isStopped = false;
        hasAction          = false;

        yield break;
    }
コード例 #2
0
 private void Patrol()
 {
     if (CharUtil.IsTargetWithinRange(transform, playerTransform.position, visibleRange))
     {
         StartChasing();
     }
     else if (CharUtil.IsTargetWithinRange(transform, playerTransform.position, 1f))
     {
         StartIdling();
     }
 }
コード例 #3
0
 private void Idle()
 {
     if (CharUtil.IsTargetWithinRange(transform, playerTransform.position, visibleRange))
     {
         StartChasing();
     }
     else if (outIdleDuration <= 0f)
     {
         StartPatrol();
     }
     else
     {
         outIdleDuration -= Time.deltaTime;
     }
 }
コード例 #4
0
 private void Chase()
 {
     if (CharUtil.IsTargetWithinRange(transform, playerTransform.position, visibleRange))
     {
         if (CharUtil.IsTargetWithinRange(transform, playerTransform.position, attackRange))
         {
             StartCoroutine(StartAttack());
         }
         else
         {
             navAgent.SetDestination(playerTransform.position);
         }
     }
     else
     {
         StartIdling();
     }
 }