Examples of MapData


Examples of civquest.map.MapData

  public void afterGameChanged(MoveUnit moveUnit) {
    process(moveUnit, false, true);
  }

  private void process(MoveUnit moveUnit, boolean before, boolean after) {
    MapData mapData = Game.getMapData();
   
    Long unitID = moveUnit.getUnitID();
    Long ownerID = mapData.getUnit(unitID).getOwnerID();
    Coordinate from = moveUnit.getFrom();
    Coordinate to = moveUnit.getTo();
    if (manager.getNationID().equals(ownerID)) {
      if (after) {
        manager.unitMoved(from, to);
      }
      moveUnit.notify(manager.getRestrictedToNation(), before, after);
    } else {
      if (manager.isCompleteVisible(from)) {
        if (manager.isCompleteVisible(to)) {
          moveUnit.notify(manager.getRestrictedToNation(), before, after);
        } else {
          RemoveUnit removeUnit = new RemoveUnit(manager.getRestrictedToNation(),
                               unitID);
          removeUnit.notify(before, after);
          if (before) {
            manager.removeForeignUnit(unitID);
          }
        }
      } else {
        if (manager.isCompleteVisible(to)) {
          if (after) {
            manager.addForeignUnit(unitID);
          }
          ConstructUnit constructUnit
            = new ConstructUnit(manager.getRestrictedToNation(),
                      mapData.getMapObjectPosition(unitID),
                      mapData.getMapObjectOwner(unitID));
          constructUnit.notify(before, after);
        } else {
          // do nothing, nothing is visible
        }
      }
View Full Code Here

Examples of civquest.map.MapData

    protected Registry guiregistry;
  protected ImageSet topImageSet;
    protected boolean positionHelp;

    public MapViewComponent(Registry registry, ImageSet topImageSet) throws RulesetException {
    MapData mapData = Game.getMapData();

        mapWidth = mapData.getArrayWidth();
        mapHeight = mapData.getArrayHeight();
    arrayWidth = mapData.getArrayWidth();
    arrayHeight = mapData.getArrayHeight();
    this.topImageSet = topImageSet;
    guiregistry = registry.getSubRegistry("gui");
    }
View Full Code Here

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

Examples of civquest.map.MapData

//         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

Examples of civquest.map.MapData

    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

Examples of civquest.map.MapData

        }   
  }

    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

Examples of civquest.map.MapData

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

Examples of civquest.map.MapData

    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

Examples of civquest.map.MapData

    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

Examples of civquest.map.MapData

    }
    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
TOP
Copyright © 2018 www.massapi.com. 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.