public override void Enter()
 {
     Collider[] hits = hidingAreaDetector.GetCollisionsInArea();
     if (hits.Length > 0)
     {
         GameObject target = hits[0].gameObject;
         Hide();
         StartCoroutine(CheckIfStillInHidingRange());
     }
     else
     {
         ChangeToShooting();
     }
 }
 public override void Enter()
 {
     Collider[] hits = fightAreaDetector.GetCollisionsInArea();
     if (hits.Length > 0)
     {
         GameObject target = hits[0].gameObject;
         base.SetAnimationBool("Fighting", true);
         StartCoroutine(Fight(target.transform));
         StartCoroutine(CheckIfStillInFightingRange());
     }
     else
     {
         ChangeToChasing();
     }
 }
Esempio n. 3
0
 private IEnumerator CheckIfInShootingRange()
 {
     Collider[] hits = areaDetector.GetCollisionsInArea();
     while (true)
     {
         if (hits.Length == 0) // player not in range
         {
             hits = areaDetector.GetCollisionsInArea();
         }
         else if (areaDetector.GetHasLineOfSight(hits[0].transform))
         {
             ChangeToShooting();
         }
         yield return(null);
     }
 }
Esempio n. 4
0
 private IEnumerator CheckIfInHidingRange()
 {
     Collider[] hits = hidingAreaDetector.GetCollisionsInArea();
     while (true)
     {
         foreach (Collider hit in hits)
         {
             if (hit.tag == "Player")
             {
                 ChangeToHiding();
             }
         }
         hits = hidingAreaDetector.GetCollisionsInArea();
         yield return(null);
     }
 }
Esempio n. 5
0
    public override void Enter()
    {
        Collider[] hits = shootingAreaDetector.GetCollisionsInArea();
        if (hits.Length > 0)
        {
            GameObject target = hits[0].gameObject;
            StartCoroutine(ShootingLoop(target.transform));
            StartCoroutine(CheckIfStillInShootingRange());
            StartCoroutine(CheckIfInHidingRange());
        }
        else
        {
            ChangeToIdle();
        }

        FMODUnity.RuntimeManager.PlayOneShot(sfxRangedEnemyDigUp, transform.position);
    }
Esempio n. 6
0
    public override void Enter()
    {
        agent.isStopped = false;
        base.SetAnimationBool("Walking", true);

        Collider[] hits = chaseAreaDetector.GetCollisionsInArea();
        if (hits.Length > 0)
        {
            GameObject target = hits[0].gameObject;
            StartCoroutine(Chase(target.transform));
            StartCoroutine(CheckIfStillInChasingRange(target.transform));
            StartCoroutine(CheckIfInFightingRange());
        }
        else
        {
            ChangeToPatrolling();
        }
    }