Ejemplo n.º 1
0
      @Override
      public boolean doMission(LittleMan actor) {

        if (actMission == missionList.length) {
          actor.setCarryObject(null);
          if (workrounds == 0) {
            if (!mill.isActive()) {
              mill.setActive(true);
            } else {
              return false;
            }
          }
          if (workrounds < 60) {
            workrounds++;
            actMission--;
            return false;
          } else {
            mill.setActive(false);
            actor.setCarryObject(new Flour());
            home.missionCompleted(this);
            return true;
          }

        } else {
          if (missionList[actMission].doMission(actor)) {
            actMission++;
            return false;
          }
          return false;
        }
      }
Ejemplo n.º 2
0
  @Override
  public void doLogic(int i) {
    super.doLogic(i);

    if (!hasAllFarms && i % 10 == 0) {
      lookForFarms();
    }

    if (super.getCurrentWorkersAmount() < super.getMaxWorkers()) {
      super.callWorker();
    }

    for (LittleMan worker : getCurrentWorkers()) {
      if (!worker.hasMission()) {
        // fabricate asked first, highest priority
        if (!outStock.isFull() && inStock.getExpectedStock() > 0) {
          worker.addMission(
              new Mission_Fabricate(
                  getWorkPos(), 30, this, Grain.class.getSimpleName(), new Flour()));
        } else {
          // check farms for grain and collect it
          for (Farm f : farms) {
            // System.out.println("farm outstock: "+ f.getOutStock().getExpectedStock() +"  mill
            // instock: "+ inStock.getExpectedStock() +"   limit: "+ inStock.getLimit());
            if (f.getOutStock().getExpectedStock() > 0
                && inStock.getExpectedStock() < inStock.getLimit()) {
              worker.addMission(
                  new Mission_PickUp(
                      f.getOutStock(), inStock, Grain.class.getSimpleName(), getWorkers().get(0)));
              break;
            }
          }
        }
      }
    }
  }