Exemple #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;
 }
Exemple #2
0
  /**
   * Returns the map grid squares that are within radius of location
   *
   * @param location The location that serves as the center of the area
   * @param radius The radius of the area
   * @return The map grid squares in the area
   */
  public ArrayList<MapGridSquare> getArea(Location location, int radius) {
    ArrayList<MapGridSquare> mapGridSquares = new ArrayList<MapGridSquare>();

    for (int x = location.getX() - radius + 1; x <= location.getX() + radius - 1; x++) {
      if (x < 0 || x > mapSize[0] - 1) {
        continue;
      }

      for (int z = location.getZ() - radius + 1; z <= location.getZ() + radius - 1; z++) {
        if (z < 0 || z > mapSize[1] - 1) {
          continue;
        }

        MapGridSquare mapGridSquare = this.map.get(new Location(x, z));
        if (!(mapGridSquare.isEmpty())) {
          mapGridSquares.add(mapGridSquare);
        }
      }
    }

    return mapGridSquares;
  }