danpost wrote...
By the way, all Recolector objects ARE also Auto type objects, because Recolector is a subclass of Auto.
addObject(new Recolector(), 38, 702);
despacharRecolector(1); despacharRecolector(2); despacharRecolector(3); despacharRecolector(4); despacharRecolector(5);
// the timer field private int dispatchTimer; // in act if (dispatchTimer % 500 == 0) despacharRecolector( dispatchTimer/500+1 ); // add truck every 500 acts if (dispatchTimer == 2000) dispatchTimer = -1; // indicate timer has completed its course if (dispatchTimer >= 0) dispatchTimer++; // increment timer if has not complete its course
private boolean despachardeNuevo(){
if (((Recolector)getObjectsAt(831,63, Recolector.class).get(0)).getNecesitaCarro()){ //if the object at that point needs a new truck because its router was never completed.
return true;
}
else private boolean despachardeNuevo(){
if (((Recolector)getObjects(Recolector.class).get(0)).getNecesitaCarro()){ //if any of the objects need a new truck because its router was never completed.
return true;
}
else public void act()
{
generatePath();
if ((despachoTimer % 500 == 0) && i<5 ){
despacharRecolector( despachoTimer/500+1 ); // add truck every 500 acts THIS WORKS!
i++;
}
if (despachoTimer == 2000) despachoTimer = -1; // indicate timer has completed its course
if (despachoTimer >= 0) despachoTimer++; // increment timer if has not complete its course
if ((i>=5)) {
if (despachardeNuevo()){ //THIS DOES NOT WORK.
despacharRecolector(((Recolector)getObjects(Recolector.class).get(0)).getnumRuta());
}
} if (capacidad<randomNum){
necesitacarro=true; //this is true when it has to be true.
}if (foundrelleno()){ //if found the end of the route
if (necesitacarro=true) enviarcarro=true; /*if the truck at any point needed a car, at the end of its route he sends the information to the world. */
// this also was true only when it had to be.
descarga();
} public boolean getNecesitaCarro(){
return enviarcarro; //which is only true at the end of the route if at some point the truck needed a car.
}((Ambiente)getWorld()).despacharRecolector(routeNum);
if (necesitacarra=true) ...
if (capacidad<randomNum){ //if the truck capacity if smaller than the randomNum which is the amount of garbage.
necesitacarro=true; //then it can't pick up the garbabe so another truck is needed to do so.
} if (foundrelleno()){ //end of route
descarga();
if (necesitacarro==true){
((Ambiente)getWorld()).despacharRecolector(numruta);
}
}if (necesitacarra) {
((Ambiente)getWorld()).despacharRecolector(numruta);
necesitacarra = false;
}if (capacidad<randomNum){
necesitacarro=true;
} if (recogido){randomNum=Greenfoot.getRandomNumber(250);
}
if (pauseTimer<=0 && (numruta!=0) ){
moverse(); //this is the method for turning depending on 'pasos'.
move(1);
pasos++; //this is my guide for turnung
pasosaux++; //this is for starting the route in different points.
}
if(haybasura() && (capacidad>randomNum) && empezarrecoleccion()) { /*if theres garbage, it can pick up because capacity is bigger than the amount of garbage and it can start picking up*/
pauseTimer=361;
recoger(); //pick up
}
if (pauseTimer > 0) pauseTimer -= 2;
if (pauseTimer < 0 && getOneObjectAtOffset(0, 0, Punto.class) == null) {
pauseTimer = 0; // stops picking up
}
if (foundrelleno()){
if (necesitacarro==true)
((Ambiente)getWorld()).despacharRecolector(numruta);
descarga();
}
if (capacidad<randomNum){ //this condition is always met, why?
necesitacarro=true;
} private void descarga()
{
if (relleno!=null){ //relleno= container
relleno.descargar(capacidad);
eliminar(); //call to delete the truck
}
}
private void eliminar()
{
if (isTouching(Relleno.class)) {
getWorld().removeObject(this);
}
}
if (foundrelleno()){ //end of route
if (necesitacarro) ((Ambiente)getWorld()).despacharRecolector(numruta);
descarga();
}