Exemplo n.º 1
0
 public void Comer()
 {
     if (bocadillos.hormigaSeleccionada != null && bocadillos.hormigaSeleccionada == this)
     {
         if (!this.agente.isOnOffMeshLink)
         {
             bocadillos.Comer();
         }
         else
         {
             bocadillos.Nada();
         }
     }
     if (comidaAComer == null)
     {
         //Debug.Log("No tengo comida aun ");
         //comidaAComer = reina.pedirComida();
         if (reina.comidaTotal.Count > 0)
         {
             //Debug.Log("Hay comida");
             comidaAComer = reina.comidaTotal[Random.Range(0, reina.comidaTotal.Count)];
             //reina.ComidaTotal.Remove(comidaAComer);
         }
         // Comprobamos si podemos o no acceder a comida
         if (comidaAComer != null)
         {
             //Debug.Log("VOY A LA PUTA COMIDA");
             agente.SetDestination(comidaAComer.transform.position);
             Task.current.Succeed();
             return;
         }
         else
         {
             Task.current.Fail();
             return;
         }
     }
     else
     {
         if (Vector3.Distance(this.transform.position, comidaAComer.transform.position) < 0.2f)
         {
             //Debug.Log("He llegado a la comida");
             hambre      += comidaAComer.Comer();
             comidaAComer = null;
             Task.current.Succeed();
             return;
         }
         else
         {
             agente.SetDestination(comidaAComer.transform.position);
             //Debug.Log("Posicion comida a comer: " + comidaAComer.transform.position);
         }
         //Debug.Log("Intentando ira porla comida");
         Task.current.Succeed();
         return;
     }
 }