public PursuitState(StatePatternCritter activeCritter)
    {
        critter = activeCritter;
        MeshArea = NavMesh.GetAreaFromName("Brick") * 4; // MeshArea = 1 << NavMesh.GetNavMeshLayerFromName("Brick");

        killZone = critter.navMeshRadius * 0.5f;
    }
    public EnterState(StatePatternCritter activeCritter)
    {
        critter = activeCritter;

        SetDurations();
        MeshArea = NavMesh.GetAreaFromName("Brick") * 4; //MeshArea = 1 << NavMesh.GetNavMeshLayerFromName("Brick");

        Debug.Log("" + critter.ID.ToString() + " I am in the EnterState! ");
    }
 public void HandlePredator( StatePatternCritter predator )
 {
     if ( critter.gameObject.CompareTag("Herbivore") )  // Are we a Herbivore?
     {
         foreach ( int predatorID in critter.predatorList )
         {
             if ( predator.ID == predatorID )
             {
                 // Debug.Log( "IdleState " + critter.ID.ToString() + " RUUUUUNN!!! " + predator.ID.ToString() );
                 ToFlightState(predator);
             }
         }
     }
 }
 public void HandleHerbivore( StatePatternCritter herbivore )
 {
     if ( critter.gameObject.CompareTag("Predator") )  // Are we a Predator?
     {
         foreach ( int herbID in critter.preyList )
         {
             if ( herbivore.ID == herbID )
             {
                 if (Random.value < 0.01) {
                     ToPursuitState(herbivore);
                     break;
                 }   // This is where we will initiate chase;
             }
         }
     }
 }
    public void HandlePredator( StatePatternCritter predator )
    {
        if ( critter.gameObject.CompareTag("Herbivore") )  // Are we a Herbivore?
        {
            foreach ( int predatorID in critter.predatorList )
            {
                if ( predator.ID == predatorID )
                {
                    critter.predator = predator;

                    // Debug.Log( "FlightState " + critter.ID.ToString() + " RUUUUUNN!!! " + predator.ID.ToString() );
                    Vector3 direction = (critter.transform.position - critter.predator.transform.position).normalized;

                    Vector3 destination = critter.transform.position + direction * fleeingDistance;

                    // Sample the provided Mesh Area and get the nearest point
                    NavMesh.SamplePosition( destination, out hit, Random.Range( 0f, critter.maxWalkDistance), MeshArea  );

                    critter.navMeshAgent.SetDestination( hit.position );
                }
            }
        }
    }
 public void ToPursuitState(StatePatternCritter prey)
 {
 }
 public void ToFlightState(StatePatternCritter predator)
 {
 }
 public void HandleHerbivore( StatePatternCritter herbivore )
 {
 }
 public FlightState(StatePatternCritter activeCritter)
 {
     critter = activeCritter;
     MeshArea = NavMesh.GetAreaFromName("Brick") * 4;// 1 << NavMesh.GetNavMeshLayerFromName("Brick");
 }
 public ExitState(StatePatternCritter activeCritter)
 {
     critter = activeCritter;
 }
 public void ToFlightState(StatePatternCritter predator)
 {
     SetDurations();
     critter.navMeshAgent.avoidancePriority = 20;
     critter.predator = predator;
     // critter.predator.meshRendererFlag.material.color = Color.red;
     critter.currentState = critter.flightState;
 }
 public WanderState(StatePatternCritter activeCritter)
 {
     critter = activeCritter;
     SetDurations();
     MeshArea = NavMesh.GetAreaFromName("Brick") * 4;
 }
 public void ToPursuitState(StatePatternCritter prey)
 {
     SetDurations();
     critter.prey = prey;
     critter.navMeshAgent.avoidancePriority = 20;
     critter.currentState = critter.pursuitState;
 }
 public void ToFlightState(StatePatternCritter predator)
 {
     SetDurations();
     critter.predator = predator;
     critter.navMeshAgent.avoidancePriority = 20;
     critter.currentState = critter.flightState;
 }
 public IdleState(StatePatternCritter activeCritter)
 {
     critter = activeCritter;
     SetDurations();
 }
    public void ToFlightState(StatePatternCritter predator)
    {
        // critter.navMeshObstacle.enabled = false;

        SetDurations();
        critter.navMeshAgent.avoidancePriority = 20;
        critter.predator = predator;
        critter.currentState = critter.flightState;
    }