Пример #1
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);
     }
 }
Пример #2
0
    IEnumerator CheckIfStillInChasingRange(Transform target)
    {
        yield return(null);

        Collider[] hits = chaseAreaDetector.GetCollisionsInArea();
        while (hits.Length > 0)
        {
            if (!chaseAreaDetector.GetHasLineOfSight(hits[0].transform))
            {
                // TODO: Fazer com que inimigo vá até o último lugar visto antes de voltar a patrulhar
                break;
            }
            hits = chaseAreaDetector.GetCollisionsInArea();
            yield return(null);
        }
        ChangeToPatrolling();
    }
    IEnumerator CheckIfStillInFightingRange()
    {
        yield return(null);

        targetInRange = true;
        Collider[] hits = fightAreaDetector.GetCollisionsInArea();

        while (true)
        {
            if (hits.Length > 0 && fightAreaDetector.GetHasLineOfSight(hits[0].transform))
            {
                hits = fightAreaDetector.GetCollisionsInArea();
            }
            else
            {
                targetInRange = false;
                yield return(chaseDelayWFS);

                ChangeToChasing();
            }
            yield return(null);
        }
    }