Package com.drakulo.games.ais.core

Examples of com.drakulo.games.ais.core.Colony


    // TODO externalize this part
    // Load the tiledmap
    TiledMap tiledMap = new TiledMap("data/testmap.tmx");

    Colony c = new Colony();
    c.setAvailableRobots(3);
    c.setTotalRobots(3);
    c.setMap(tiledMap);
    c.setName("Anthem Base");

    Resource[] resources = Resource.values();
    for (Resource r : resources) {
      c.setResource(r, BigDecimal.valueOf(1000));
    }

    c.setResearchCenterBuilt(false);
    GameData.addColony(c);
    GameData.setSelectedColony(c);
    // /////////////////////////

    // End of to externalize zone
View Full Code Here


  }

  @Override
  public void renderState(Graphics g) throws SlickException {
    // Render the tiled map view port
    Colony c = GameData.getSelectedColony();
    GameData.getCurrentMap().render(c.getViewportX(), c.getViewportY(),
        TileHelper.DECO_LAYER);

    // Render the buildings
    renderBuildings(g);
View Full Code Here

            @Override
            public void run() {
              if (ResourceHelper.enoughResourcesFor(sa
                  .getCostMap())) {
                sa.setLinkedBuilding(SectorState.this.selectedBuilding);
                final Colony cc = GameData.getSelectedColony();
                for (Resource r : Resource.values()) {
                  BigDecimal d = sa.getCostMap().get(r);
                  if (d == null) {
                    continue;
                  }
                  cc.updateResource(r, d.negate());
                }
                GameData.getSelectedColony().addSpecialAction(
                    sa);
              } else {
                // TODO Play error sound
View Full Code Here

      g.setColor(b.getCategory().getColor());
      g.fill(rect);
    }

    g.setColor(Color.white);
    Colony c = GameData.getSelectedColony();
    BigDecimal vpX = BigDecimal.valueOf(c.getViewportX()).negate()
        .add(scaledX);
    BigDecimal vpY = BigDecimal.valueOf(c.getViewportY()).negate()
        .add(scaledY);
    final int width = SectorState.VIEWPORT_WIDTH;
    final int height = SectorState.VIEWPORT_HEIGHT;

    g.draw(new Rectangle(vpX.intValue(), vpY.intValue() + SectorState.TOP_BAR_HEIGHT, width, height));
View Full Code Here

          .multiply(this.mapHeight).divide(HEIGHT, 0);

      mX = mX.subtract(BigDecimal.valueOf(Settings.WIDTH / 2));
      mY = mY.subtract(BigDecimal.valueOf(Settings.HEIGHT / 2));

      Colony c = GameData.getSelectedColony();
      c.setViewportX(-mX.intValue());
      c.setViewportY(-mY.intValue());
    }
  }
View Full Code Here

    this.createColonyButton.setWidth(80);
    this.createColonyButton.setActionHandler(new ActionHandler() {

      @Override
      public void run() {
        final Colony c = new Colony();
        c.setName(PlanetState.this.colonyNameField.getText());
        PlanetState.this.colonyNameField.setText("");
        try {
          c.setMap(new TiledMap("data/testmap.tmx"));
        } catch (SlickException e) {
          // TODO Handle TiledMap loading in a manager
          e.printStackTrace();
        }
        c.setResource(Resource.CRISTAL, BigDecimal.valueOf(1000));
        c.setResource(Resource.ENERGY, BigDecimal.valueOf(1000));
        c.setResource(Resource.FOOD, BigDecimal.valueOf(1000));
        c.setResource(Resource.GAS, BigDecimal.valueOf(1000));
        final int selectedIndex = PlanetState.this.map
            .getSelectedZone();

        final HexagonMapAction a = new HexagonMapAction(2,
            PlanetState.this.map, PlanetState.this.map
View Full Code Here

      public void run() {
        System.out.println("From : " + comboFrom.getSelected());
        if (comboFrom.getSelected() == -1) {
          return;
        }
        Colony c = colonyList.getEntry(comboFrom.getSelected());
        resourceDispFrom.setMap(ResourceHelper.cloneMap(c
            .getResources()));
      }
    });
    twlRootPane.add(comboFrom);

    resourceDispFrom = new ResourceDisplay(twlRootPane, x, y + comboHeight
        + 10);

    x = getOX() + getWidth() - 6 - 10 - comboWidth;
    comboTo = new ComboBox<Colony>(colonyList);
    comboTo.setTheme("listbox");
    comboTo.setSize(comboWidth, comboHeight);
    comboTo.setPosition(x, y);
    comboTo.addCallback(new Runnable() {

      @Override
      public void run() {
        if (comboTo.getSelected() == -1) {
          return;
        }
        Colony c = colonyList.getEntry(comboTo.getSelected());
        resourceDispTo.setMap(ResourceHelper.cloneMap(c.getResources()));
      }
    });
    twlRootPane.add(comboTo);

    resourceDispTo = new ResourceDisplay(twlRootPane, x, y + comboHeight
View Full Code Here

      // TODO play an error sound
      // TODO display an error message
      return;
    }
   
    final Colony sender = comboFrom.getModel().getEntry(from);
    final Colony receiver = comboTo.getModel().getEntry(to);
    // Is there enough resource in the sender colony?
    Map<Resource, BigDecimal> map = new HashMap<Resource, BigDecimal>();
    Resource[] resources = Resource.values();
    for (Resource r : resources) {
      String strVal = fields.get(r).getText();
      if ("".equals(strVal)) {
        strVal = "0";
      }
      BigDecimal value = BigDecimal.valueOf(Long.valueOf(strVal));
      map.put(r, value);
    }
    if (!ResourceHelper.enoughResourcesFor(map, sender)) {
      // TODO play an error sound
      // TODO display an error message
      return;
    }

    // Is there enough space in the target colony?
    if (!ResourceHelper.enoughSpaceFor(map, receiver)) {
      // TODO play an error sound
      // TODO display an error message
      return;
    }

    // Everything is allright, resources can be transfered
    // Remove from sender and add to receiver...
    for (Resource r : resources) {
      // Send...
      sender.updateResource(r, map.get(r).negate());
      // Receive...
      receiver.updateResource(r, map.get(r));
    }
    hide();
  }
View Full Code Here

  protected void updateSenderData() {
    if (comboFrom.getSelected() == -1) {
      return;
    }
    Colony c = colonyList.getEntry(comboFrom.getSelected());
    resourceDispFrom.setMap(ResourceHelper.cloneMap(c.getResources()));
  }
View Full Code Here

  protected void updateReseiverData() {
    if (comboTo.getSelected() == -1) {
      return;
    }
    Colony c = colonyList.getEntry(comboTo.getSelected());
    resourceDispTo.setMap(ResourceHelper.cloneMap(c.getResources()));
  }
View Full Code Here

TOP

Related Classes of com.drakulo.games.ais.core.Colony

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.