Package com.drakulo.games.ais.core.building

Examples of com.drakulo.games.ais.core.building.BuildingLevelData


    return null;
  }

  @SuppressWarnings("unchecked")
  private static BuildingLevelData buildLevelData(Element root) {
    BuildingLevelData levelData = new BuildingLevelData();

    // Production
    Element production = root.getChild("production");
    levelData.setProduction(buildResourceMap(production));

    // Consumption
    Element consumption = root.getChild("consumption");
    levelData.setConsumption(buildResourceMap(consumption));

    // Store
    Element store = root.getChild("store");
    levelData.setStoreCapacity(buildResourceMap(store));

    // Upgrade
    Element upgrade = root.getChild("upgrade");
    levelData.setUpgradeCost(buildResourceMap(upgrade));

    // Technologies needed to upgrade
    Element techs = root.getChild("technologies");
    if (techs == null) {
      levelData.setTechnologiesNeeded(null);
    } else {
      List<String> technologies = new ArrayList<String>();
      List<Element> children = techs.getChildren("technology");
      for (Element elem : children) {
        technologies.add(elem.getText());
      }
      levelData.setTechnologiesNeeded(technologies);
    }

    // Special actions
    Element actions = root.getChild("special");
    if (actions == null) {
      levelData.setSpecialActions(null);
    } else {
      List<String> actionList = new ArrayList<String>();
      List<Element> children = actions.getChildren("action");
      for (Element elem : children) {
        // Create the special action
        String name = elem.getChildText("name");
        int duration = Integer.valueOf(elem.getChildText("duration"))
            .intValue();
        Map<Resource, BigDecimal> costMap = buildResourceMap(elem
            .getChild("cost"));
        String gfxKey = elem.getChildText("gfx");
        String i18nKey = elem.getChildText("i18n");
        SpecialActionManager.create(name, duration, costMap, gfxKey,
            i18nKey);

        actionList.add(name);
      }
      levelData.setSpecialActions(actionList);
    }

    return levelData;
  }
View Full Code Here


   *            - the building type
   * @return the created button
   */
  private Button createBuildingButton(final BuildingType type) {
    // Load the building cost
    BuildingLevelData data = BuildingIO.getBuildingData(type).getLevelData(
        0);
    final Map<Resource, BigDecimal> costMap = data.getUpgradeCost();

    // Create the button
    ImageButton button = new ImageButton(type.toString());
    button.setTitle(I18n.get(type.getI18n()));
    // Set the build action
    button.setActionHandler(new ActionHandler() {

      @Override
      public void run() {
        BuildingAction ba = BuildingHelper.createAction(
            GameData.getSelectedColony(), type, costMap);
        parent.setSelectedAction(ba);
        hide();
      }
    });
    // Set the hover action
    button.setHoverHandler(new ActionHandler() {

      @Override
      public void run() {
        final String desc = I18n.get(type.getDescI18n());
        displayBuildingData(desc, costMap);
        hoverFlag = true;

        BuildingLevelData data = BuildingIO.getBuildingData(type)
            .getLevelData(0);
        BuildWindow.this.costMap = data.getUpgradeCost();
        earnMap = data.getProduction();
      }
    });
    button.disable();
    button.hide();
    parent.add(button);
View Full Code Here

      }
    }

    // Upgrade button
    if (this.selectedBuilding != null) {
      BuildingLevelData data = BuildingIO.getBuildingData(
          this.selectedBuilding.getType()).getLevelData(
          this.selectedBuilding.getLevel());
      if (this.buildingButtons[0][2].isHovered()) {
        // The upgrade button is hovered : show the resources needed
        showUpgradeCost(data.getUpgradeCost(), g,
            this.buildingButtons[0][2]);
      } else {
        hideUpgradeLabels();
      }

      // Rendering of special building actions
      if (data.getSpecialActions() != null) {
        // There id some special action to show
        int col = 0;
        int row = 0;
        for (String name : data.getSpecialActions()) {
          final ColonyAction sa = SpecialActionManager.get(
              GameData.getSelectedColony(), name);
          ImageButton btn = this.buildingButtons[col][row];
          btn.setImageRef(sa.getGfxKey());
          btn.setActionHandler(new ActionHandler() {
View Full Code Here

    y += 25;
    x = startX;

    BuildingData data = BuildingIO.getBuildingData(this.selectedBuilding
        .getType());
    BuildingLevelData levelData = data.getLevelData(this.selectedBuilding
        .getLevel());
    Map<Resource, BigDecimal> prod = levelData.getProduction();
    Map<Resource, BigDecimal> cons = levelData.getConsumption();
    Map<Resource, BigDecimal> store = levelData.getStoreCapacity();
    Resource[] resources = Resource.values();
    for (Resource r : resources) {
      // TODO Row label
      Label rowLabel = this.buildingRowLabels.get(r);
      rowLabel.setVisible(true);
View Full Code Here

    // Show useful buttons
    // Upgrade button is shown if there is another level for the building
    BuildingData data = BuildingIO.getBuildingData(this.selectedBuilding
        .getType());
    BuildingLevelData nextLevel = data.getLevelData(this.selectedBuilding
        .getLevel() + 1);
    if (nextLevel != null) {
      // There is a level
      this.buildingButtons[0][2].show();
      // Is it OK with technologies?
      if (TechnologyHelper.technologiesAreOwned(nextLevel
          .getTechnologiesNeeded())) {
        // OK but... Is there an action ongoing?
        if (!actionOngoing) {
          this.buildingButtons[0][2].enable();
        }
View Full Code Here

   * @param b
   *            the building to upgrade
   */
  private void upgradeBuilding(final Building b) {
    // Check resources
    BuildingLevelData levelData = BuildingIO.getBuildingData(b.getType())
        .getLevelData(b.getLevel());
    Map<Resource, BigDecimal> costMap = levelData.getUpgradeCost();
    // Enough resources ?
    if (ResourceHelper.enoughResourcesFor(costMap)) {
      Resource[] resources = Resource.values();
      for (Resource r : resources) {
        if (costMap.get(r) == null) {
View Full Code Here

TOP

Related Classes of com.drakulo.games.ais.core.building.BuildingLevelData

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.