Package com.drakulo.games.ais.core.delayed

Examples of com.drakulo.games.ais.core.delayed.PreparationAction


  public static PreparationAction create(Colony c) {
    Map<Resource, BigDecimal> costMap = new HashMap<Resource, BigDecimal>();
    // TODO externalize cost
    costMap.put(Resource.ENERGY, BigDecimal.valueOf(25));
    PreparationAction pa = new PreparationAction(c, costMap, 5);
    return pa;
  }
View Full Code Here


    return pa;
  }

  public static void createCMConstructionCallback(int x, int y, final Colony c) {
    // Ground preparation
    PreparationAction pa00 = createCleaningAction(c, x - 1, y - 1);
    PreparationAction pa10 = createCleaningAction(c, x, y - 1);
    PreparationAction pa20 = createCleaningAction(c, x + 1, y - 1);
    PreparationAction pa01 = createCleaningAction(c, x - 1, y);
    PreparationAction pa21 = createCleaningAction(c, x + 1, y);
    PreparationAction pa02 = createCleaningAction(c, x - 1, y + 1);
    PreparationAction pa12 = createCleaningAction(c, x, y + 1);
    PreparationAction pa22 = createCleaningAction(c, x + 1, y + 1);

    // Road construction
    BuildingAction n = createBuildingAction(c, x, y - 1, BuildingType.ROAD);
    BuildingAction e = createBuildingAction(c, x + 1, y, BuildingType.ROAD);
    BuildingAction w = createBuildingAction(c, x - 1, y, BuildingType.ROAD);
View Full Code Here

    c.addPreparationAction(pa10);
    c.addPreparationAction(pa20);
  }

  private static PreparationAction createCleaningAction(Colony c, int x, int y) {
    PreparationAction pa = new PreparationAction(c, null, 5);
    pa.setX(x);
    pa.setY(y);
    return pa;
  }
View Full Code Here

      @Override
      public void run() {
        for (DelayedAction da : children) {
          if (da instanceof PreparationAction) {
            PreparationAction pa = (PreparationAction) da;
            c.addPreparationAction(pa);
          } else if (da instanceof BuildingAction) {
            BuildingAction ba = (BuildingAction) da;
            c.addBuildingAction(ba);
View Full Code Here

        ImageButton.IB_DEFAULT_SIZE);
    terrabotButton.setActionHandler(new ActionHandler() {

      @Override
      public void run() {
        PreparationAction pa = BuildingHelper.create(GameData.getSelectedColony());
        BuildWindowOld.this.parent.setSelectedAction(pa);
        hide();
      }
    });
    terrabotButton.setHoverHandler(new ActionHandler() {
View Full Code Here

    terrabotButton.disable();
    terrabotButton.setActionHandler(new ActionHandler() {

      @Override
      public void run() {
        PreparationAction pa = BuildingHelper.create(GameData
            .getSelectedColony());
        BuildWindow.this.parent.setSelectedAction(pa);
        hide();
      }
    });
View Full Code Here

          && this.mouseY < Settings.HEIGHT - BOTTOM_BAR_HEIGHT) {
        final int tileX = this.squareXOnMap;
        final int tileY = this.squareYOnMap;
        if (this.selectedAction instanceof PreparationAction) {
          // Preparation action
          PreparationAction pa = (PreparationAction) this.selectedAction;
          boolean canBuild = false;
          if (TileHelper.tileIsPreparable(tileX, tileY)) {
            // Tile is OK
            if (ResourceHelper
                .enoughResourcesFor(SectorState.this.selectedAction
                    .getCostMap())) {
              // Resources are OK
              if (GameData.getSelectedColony()
                  .getAvailableRobots() > 0) {
                canBuild = true;
              }
            }
          }
          if (canBuild) {
            // Preparation can be done
            pa.setX(tileX);
            pa.setY(tileY);
            Map<Resource, BigDecimal> map = pa.getCostMap();
            for (Resource r : resources) {
              if (map.get(r) == null) {
                // No value defined for this resource
                continue;
              }
              GameData.getSelectedColony().updateResource(r,
                  map.get(r).negate());
            }

            GameData.getSelectedColony().addPreparationAction(
                pa.clone());
          } else {
            // TODO play an error sound
          }

        } else if (this.selectedAction instanceof BuildingAction) {
View Full Code Here

TOP

Related Classes of com.drakulo.games.ais.core.delayed.PreparationAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.