示例#1
0
 private void Update()
 {
     if (player.GetComponent <Health>().GetIsDead() && !GetComponent <Health>().GetIsDead())
     {
         GetComponent <NavMeshAgent>().isStopped = true;
     }
     if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Attack"))
     {
         if (!GetComponent <Health>().GetIsDead() && Aggro() && combatant.CanAttack(player))
         {
             playerLastSeen = 0f;
             combatant.Attack(player);
             GetComponent <NavMeshAgent>().speed = chaseSpeed;
         }
         else if (playerLastSeen < suspicionTimer)
         {
             GetComponent <ActionAgenda>().CancelCurrentAction();
         }
         else
         {
             if (isGuard && !GetComponent <Health>().GetIsDead())
             {
                 Patrol();
             }
             else
             {
                 combatant.Cancel();
             }
         }
     }
     playerLastSeen   += Time.deltaTime;
     timeSinceArrival += Time.deltaTime;
 }