Package com.drakulo.games.ais.core.tech

Examples of com.drakulo.games.ais.core.tech.Technology


      // parents and children
      Set<String> keys = map.keySet();
      for (String key : keys) {
        List<Technology> parents = new ArrayList<Technology>();
        List<Technology> children = new ArrayList<Technology>();
        Technology t = map.get(key);
        for (Technology pt : t.getParents()) {
          parents.add(map.get(pt.getId()));
        }
        for (Technology ct : t.getChildren()) {
          children.add(map.get(ct.getId()));
        }
        t.setParents(parents);
        t.setChildren(children);
      }

      calculateLevels(map);

      loadCosts(root, map);
View Full Code Here


      }
      costMap.put(level, temp);
    }

    for (String k : map.keySet()) {
      Technology t = map.get(k);
      int level = t.getLevel();
      t.setCost(costMap.get(String.valueOf(level)));
    }

  }
View Full Code Here

    List<Element> technologies = root.getChildren("technology");
    // System.out.println("===================================");
    // System.out.println("===================================");
    for (Element te : technologies) {
      Technology t = createFromNode(te);
      // System.out.println(t.getId()+".name = ");
      // System.out.println(t.getId()+".description = ");
      // System.out.println("");
      map.put(t.getId(), t);
    }
    // System.out.println("===================================");
    // System.out.println("===================================");

    return map;
View Full Code Here

    return map;
  }

  @SuppressWarnings("unchecked")
  private static Technology createFromNode(Element node) {
    Technology t = new Technology();
    String id = node.getChildText("id");
    t.setId(id);
    t.setName(I18n.getFirstToUpper(id + ".name"));
    t.setDescription(I18n.getFirstToUpper(id + ".description"));
    t.setImageKey(node.getChildText("icon"));

    List<Element> parents = node.getChild("parents").getChildren("parent");
    for (Element p : parents) {
      Technology pt = new Technology();
      pt.setId(p.getText());
      t.addParent(pt);
    }

    List<Element> children = node.getChild("children").getChildren("child");
    for (Element p : children) {
      Technology ct = new Technology();
      ct.setId(p.getText());
      t.addChild(ct);
    }

    // Debug mode
    if (Settings.IS_DEBUG) {
View Full Code Here

    // + avs / 2);

    // Render the background
    g.drawImage(this.background, 0, 0);

    Technology currentTech = GameData.getLastViewedTechnology();
    if (currentTech != null && this.uiTechnology != null) {
      // A technology is selected
      renderTechnology(g);
    } else {
      for (UITechnology uit : roots)
View Full Code Here

    for (UITechnology uit : this.roots) {
      uit.update(input);
    }

    // Display update
    Technology lastViewed = GameData.getLastViewedTechnology();
    // current = null & last != null
    boolean c1 = this.uiTechnology == null && lastViewed != null;
    // current != null & last = null
    boolean c2 = this.uiTechnology != null && lastViewed == null;
    boolean c3 = false;
    if (this.uiTechnology != null) {
      // Different technology
      c3 = !this.uiTechnology.getTechnology().equals(lastViewed);
    }

    if (c1 || c2 || c3) {
      selectTechnology(lastViewed);
    }

    if (this.uiTechnology != null) {
      this.uiTechnology.update(input);

      // Parents
      for (UITechnology uit : this.parents) {
        uit.update(input);
      }

      // Children
      for (UITechnology uit : this.children) {
        uit.update(input);
      }
    }

    // Resource progress bars updates
    Resource[] resources = Resource.values();
    for (Resource r : resources) {
      ProgressBar pb = this.resourceBars.get(r);
      pb.update(input);
    }

    // Handling research buttons
    ResearchAction action = GameData.getSelectedColony().getResearch();
    if (action == null) {
      // No research for now : authorize start research is research is
      // possible
      if (this.uiTechnology != null
          && this.uiTechnology.getTechnology().isResearchable()) {
        // The technology is researchable
        this.startResearchButton.enable();
      } else {
        // Action not possible
        this.startResearchButton.disable();
      }
      this.cancelResearchButton.disable();
      this.researchProgress.setValue(BigDecimal.ZERO);
    } else {
      // Research in progress
      Technology t = action.getTechnology();
      if (this.uiTechnology == null) {
        // The player is showing the root : disable all
        this.startResearchButton.disable();
        this.cancelResearchButton.disable();
      } else if (t.equals(this.uiTechnology.getTechnology())) {
        // The player is showing the research in pregress : authorize
        // stop button
        this.startResearchButton.disable();
        this.cancelResearchButton.enable();
      } else {
View Full Code Here

    Resource[] resources = Resource.values();
    Image img;
    Map<Resource, BigDecimal> resourceMap = GameData.getSelectedColony()
        .getResources();

    Technology t = null;
    if (uiTechnology != null) {
      t = uiTechnology.getTechnology();
    }

    Map<Resource, BigDecimal> costMap = null;
    if (t != null) {
      costMap = t.getCost();
    }

    int y = sy + height - 100;
    int x = sx + 45;
    final int rsx = x;
    for (Resource r : resources) {
      UIHelper.drawDarkBox(g, x, y += 3, 24, 20);
      img = ImageManager.getGfx(r.getGfxBase() + "-small");
      img.draw(x + 3, y, r.getColor());

      String value = resourceMap.get(r).toString();
      Label lbl = this.storeLabels.get(r);

      final int zoneHeight = 15;
      UIHelper.drawDarkBox(g, x + 24, y, lbl.getWidth() + 4, zoneHeight);
      lbl.setPosition(x + 24, y);
      lbl.setText(value);
      lbl.setVisible(true);

      x += lbl.getWidth() + 15;
      String costValue = "";
      if (costMap != null) {
        costValue = costMap.get(r).toString();
      }
      Label costLbl = this.costLabels.get(r);

      UIHelper.drawDarkBox(g, x + 24, y, costLbl.getWidth() + 4,
          zoneHeight);
      costLbl.setPosition(x + 24, y);
      costLbl.setText(costValue);
      costLbl.setVisible(true);

      y += 20;
      x = rsx;
    }

    if (t != null) {
      Font font = FontHelper.getFont(FontHelper.HEMI_HEAD, Color.white,
          25);
      font.drawString(sx + 10, sy + 10, t.getName());
      technologyDescription.setText(t.getDescription());
      technologyDescription.setPosition(sx + 10, sy += 35);
    } else {
      technologyDescription.setText("");
    }
View Full Code Here

TOP

Related Classes of com.drakulo.games.ais.core.tech.Technology

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.