Package civquest.util

Examples of civquest.util.Coordinate


  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);
View Full Code Here


  public MoveInfo getMovementChanges(Game game, MoveStep step)
    throws MovementException {

    MapObjectReader moReader = game.getMapObjectReader();
    Coordinate to = step.getTo();

    if (step.getNumberOfUnits() == 0) {
        // there are no Units to move
      throw new MovementException("UnitMover.getMovementChanges: "
                    + "Where are my Units??? "
                    + "I need them!!!");
    }

    Iterator<Long> iterator = step.getUnitIterator();
    int numberOfUnits = 1;

    // exists because of test above
    Long aUnit = iterator.next();
    Coordinate from = moReader.getMapObjectPosition(aUnit);
    // all units need to be on the same field
   
    while (iterator.hasNext()) {
      if (!(from.equals(moReader.getMapObjectPosition(iterator.next())))) {
        // for now
        throw new MovementException("UnitMover.getMovementChanges: "
                      + "All given Units need to be "
                      + "located on the same field!");
      }
      numberOfUnits++;
    }

    Long[] units = new Long[numberOfUnits];
    int z = 0;
    iterator = step.getUnitIterator();
    while (iterator.hasNext()) {
      units[z] = iterator.next();
      z++;
    }
   
    if (from.equals(to)) {
      throw new MovementException("UnitMover.getMovementChanges: "
                    + "From != To is required!");
    }
   
   
View Full Code Here

      = 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] =
            new QuadIsoLayeredFieldView(new Coordinate(x, y), nationInfo, quadMap,
                          isoRegistry.getSubRegistry("fieldviews"),
                          isoTilesImageSet,
                          new Coordinate(2 * halfCellWidth,
                                   4 * halfCellHeight),
                          this, nationInfo.getGameData());
                }
            }
        }
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

                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

    }

    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();
      }
View Full Code Here

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

    pos = adjustArrayCoordToScrolling(pos);
    return (mapData.isOnMap(pos) ? mapData.getField(pos) : null);
    }

    public Coordinate getAbsPaintCoord(Coordinate coord) {
    return new Coordinate(((coord.x - startx) - (coord.y - starty)) * halfCellWidth,
                ((coord.x - startx) + (coord.y - starty)) * halfCellHeight);
    }
View Full Code Here

    return new Coordinate(((coord.x - startx) - (coord.y - starty)) * halfCellWidth,
                ((coord.x - startx) + (coord.y - starty)) * halfCellHeight);
    }

    public Coordinate getAbsImagePaintCoord(Coordinate coord) {
    return getAbsPaintCoord(coord).sub(new Coordinate(0,2 * halfCellHeight));
    }
View Full Code Here

TOP

Related Classes of civquest.util.Coordinate

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.