Exemplo n.º 1
0
 /**
  * Updates the grid square at the specified location to include the specified type Will also
  * update the gui object, if there is one
  *
  * @param location The location to update
  * @param type The type to add
  * @param guiObjectFactory The gui object factory
  * @return The added grid square instance
  */
 public GridSquare updateGridSquare(
     Location location, String type, GuiObjectFactory guiObjectFactory) {
   MapGridSquare mapGridSquare = map.get(location);
   GridSquare gridSquare =
       (GridSquare) ObjectFactory.createObject("content", "game.gridSquares.GridSquare" + type);
   gridSquare.initialize(
       location, (GuiGridSquareObject) guiObjectFactory.create(gridSquare.getClass(), true));
   mapGridSquare.addGridSquare(gridSquare);
   if (guiGameMap != null) {
     guiGameMap.updateMap();
   }
   return gridSquare;
 }
Exemplo n.º 2
0
  /**
   * Fills up all the locations with map grid square instances and makes sure Location knows the
   * dimensions of the map
   *
   * @param rangeX The length of the map in X direction
   * @param rangeZ The length of the map in Z direction
   * @param guiObjectFactory The gui object factory instance
   */
  public void initialize(int rangeX, int rangeZ, GuiObjectFactory guiObjectFactory) {
    mapSize[0] = rangeX;
    mapSize[1] = rangeZ;
    this.guiGameMap = (GuiGameMapObject) guiObjectFactory.create(GameMap.class, false);

    for (int x = 0; x <= rangeX - 1; x++) {
      for (int z = 0; z <= rangeZ - 1; z++) {
        Location location = new Location(x, z);
        map.put(location, new MapGridSquare(location, guiObjectFactory));
      }
    }

    Location.setMapSize(mapSize);
  }