Package civquest.map

Examples of civquest.map.MapData


     * specified by the selected vegetation and height.
     */
    private void updateMarkedFields() {
        String vegName = this.getSelectedVegetation();
        String height = this.getSelectedHeight();
        MapData mapData = Game.getMapData();
       
        Iterator<Coordinate> mfit = this.mainMapView.getActiveGroup()
            .getFieldIterator();
        for (;mfit.hasNext();) {
            Coordinate coord = mfit.next();
            Field field = mapData.getField(coord);
            field.setHeightLevel(Field.getHeightConstant(height));
            try {
                field.setValues(new VegetationData(
                        this.registry, vegName), -1, -1);
            } catch (RulesetException rse) {
View Full Code Here


//         game.nextNation();   
  }

  /** Adds a city for the given Nation somewhere on land */
  private void addACity(Nation nation) {
    MapData mapData = Game.getMapData();
    FieldReader fieldReader = Game.getGame().getFieldReader();
    CityReader cityReader = Game.getGame().getCityReader();
    Random random = new Random();
   
    int x = 0, y = 0;

    for (int n = 0; n < 100; n++) {
      x = random.nextInt(mapData.getArrayWidth());
      y = random.nextInt(mapData.getArrayHeight());
     
      if (mapData.isArrayCoordOnMap(x, y)
        && civquest.map.Field.isLand(fieldReader.getHeightLevel(new Coordinate(x, y)))
        && cityReader.getCityID(new Coordinate(x, y)) == null) {
        break;
      }
    }

    if (!mapData.isArrayCoordOnMap(x, y)) {
      Messages messages = Messages.getMessages();
      messages.info("CivQuest", "GUITestData",
              "addACity: No suitable place for a city found!");
      return;
    }
View Full Code Here

    public IsoProperties(int nhalfCellWidth,int nhalfCellHeight, QuadMap quadMap,
             Registry isoRegistry, ImageSet isoTilesImageSet)
    throws RulesetException {

    MapData mapData = Game.getMapData();   

    startx = 0;
    starty = mapData.getMapWidth() - 1;
   
    halfCellWidth = nhalfCellWidth;
    halfCellHeight = nhalfCellHeight;
    sinOfAngle = 1 / Math.sqrt(2);
    cosOfAngle = 1 / Math.sqrt(2);
View Full Code Here

        }   
  }

    private QuadFieldView[][] constructLayeredFV(NationInfo nationInfo)
    throws RulesetException {
    MapData mapData = Game.getMapData();
   
        QuadFieldView[][] fieldViews
      = new QuadIsoLayeredFieldView[mapData.getArrayWidth()][mapData.getArrayHeight()];
        for (int x = 0; x < mapData.getArrayWidth(); x++) {
            for (int y = 0; y < mapData.getArrayHeight(); y++) {
                if (mapData.isArrayCoordOnMap(x, y)) {
          if (validFieldViewCoord == null) {
            validFieldViewCoord = new Coordinate(x, y);
          }

          fieldViews[x][y] =
View Full Code Here

    return fieldViews;
    }   
   
    public Coordinate getScrollSize() {
    MapData mapData = Game.getMapData();   
    return new Coordinate(mapData.getMapWidth() * 2 * halfCellWidth,
                mapData.getMapHeight() * 2 * halfCellHeight);
    }
View Full Code Here

    return new Coordinate(mapData.getMapWidth() * 2 * halfCellWidth,
                mapData.getMapHeight() * 2 * halfCellHeight);
    }

    public Coordinate getPaintSize() {
    MapData mapData = Game.getMapData();   
    return new Coordinate((mapData.getMapWidth() * 2 + 1) * halfCellWidth,
                mapData.getMapHeight() * 2 * halfCellHeight);
    }
View Full Code Here

    return new Coordinate((mapData.getMapWidth() * 2 + 1) * halfCellWidth,
                mapData.getMapHeight() * 2 * halfCellHeight);
    }

    public Coordinate adjustArrayCoordToScrolling(Coordinate coord) {
    MapData mapData = Game.getMapData();   

    Coordinate retCoord = (Coordinate)(coord.clone());
    if (!mapData.isFlatEarth()) {
      while (retCoord.x + mapData.getArrayWidth() - retCoord.y < mapData.getMapHeight()) {
        retCoord.x += mapData.getMapWidth();
        retCoord.y -= mapData.getMapWidth();
      }
      while (mapData.getArrayWidth() - 1 - retCoord.x + retCoord.y < mapData.getMapHeight() - 2) {
        retCoord.x -= mapData.getMapWidth();
        retCoord.y += mapData.getMapWidth();
      }
    }
    return retCoord;
    }
View Full Code Here

    }
    return retCoord;
    }

    public Coordinate getUnscrolledArrayCoord(Coordinate paintCoord) {
    MapData mapData = Game.getMapData();   

    // Scaling to 1x1-fields and moving (0,0) into the northern edge of field (mapWidth - 1,0)
    double scx = paintCoord.x * xScaleFactor - (1 / Math.sqrt(2));
    double scy = paintCoord.y * yScaleFactor;
    // Turning by 45 degrees (note that we now have a coordinate-system where the fields have
    // diagonal length sqrt(2), are rectangular and the diagonals are parallel to the standard
    // x and y-axis).
    double tx = cosOfAngle * scy + sinOfAngle * scx;
    double ty = - cosOfAngle * scx + sinOfAngle * scy;
    // Move (0,0) into (0,0) in array-coords
    ty += mapData.getMapWidth() - 1;
     
    return new Coordinate((int)(Math.floor(tx)), (int)(Math.floor(ty)));
    }
View Full Code Here

  public void afterGameChanged(SetFieldRuledByCity change) {
    TurnManager turnManager = Game.getGame().getTurnManager();
    Nation currNation = turnManager.getActiveNation();
   
    Coordinate position = change.getPosition();
    MapData mapData = Game.getMapData();
    Field field = mapData.getField(position);
    Long cityID = change.getCityID();
    City city = mapData.getCity(cityID);

    throw new ResourceGraphException("Re-implement this!");
//     ResourceDistribution distribution = null;
//     ResourceDistribution distribution = city.getResourceDistribution();
View Full Code Here

     
    return new Coordinate((int)(Math.floor(tx)), (int)(Math.floor(ty)));
    }

    public civquest.map.Field getFieldByAbs(Coordinate paintCoord) {
    MapData mapData = Game.getMapData();
   
    Coordinate pos = getUnscrolledArrayCoord(paintCoord);
    pos = adjustArrayCoordToScrolling(pos);
    return (mapData.isOnMap(pos) ? mapData.getField(pos) : null);
    }
View Full Code Here

TOP

Related Classes of civquest.map.MapData

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.