示例#1
0
文件: GameMap.java 项目: Uckje/TTMO
  /**
   * 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);
  }