Package civquest.util

Examples of civquest.util.Coordinate


    }
    /** Returns for the given field, which fields its water could flow to. This are all fields that
     *  are either sea or already have a waterflow (with the exception of land-volcanos). */
    private Field[] getPossibleToFields(Field fromfield)
    {
      Coordinate from = fromfield.getPosition();
      Coordinate[] validcoords = new Coordinate[4];
      validcoords[0] = mapdata.adjustToMapSize(new Coordinate(from.x - 1,from.y));
      validcoords[1] = mapdata.adjustToMapSize(new Coordinate(from.x + 1,from.y));
      validcoords[2] = mapdata.adjustToMapSize(new Coordinate(from.x,from.y - 1));
      validcoords[3] = mapdata.adjustToMapSize(new Coordinate(from.x,from.y + 1));
      int numberofvalidcoords = 0;
      for(int n = 0;n < 4;n++
        if(validcoords[n] != null)       
          {
            Field f = mapdata.getField(validcoords[n]);
View Full Code Here


  Long getCityProvidingVisibility(Coordinate pos, Long notThisOne) {
    Iterator<Coordinate> iterator
      = Game.getMapData().getRectIterator(pos, getCityVisDistance());
    CityReader cityReader = getCityReader();
    while (iterator.hasNext()) {
      Coordinate checkPos = iterator.next();
      if (cityReader.isCityIDAvailable(checkPos)) {
        Long cityID = cityReader.getCityID(checkPos);
        if (cityID != null
          && cityReader.isCityOwnerAvailable(cityID)
          && getNationID().equals(cityReader.getCityOwner(cityID))
View Full Code Here

    } else if (unitGroups.size() > 1) {
      // Our marked own units are located on more than one field
     
    } else {
      Set<Long> group = unitGroups.iterator().next();
      Coordinate from = getPosition(group);
      Coordinate delta = getDirection();
      Coordinate to = Game.getMapData().adjustToMapSize(from.add(delta));
     
      MoveStep step = new MoveStep(group, to);

      UnitMover unitMover = quadMap.getUnitMover();
      UnitMover.MoveInfo moveInfo
View Full Code Here

    NationReader nationReader = game.getNationReader();

    Iterator<Long> unitIterator = nationReader.getAllUnits(nation.getID());
    while (unitIterator.hasNext()) {
      Long currUnitID = unitIterator.next();
      Coordinate currUnitPosition = moReader.getMapObjectPosition(currUnitID);
      makeCompleteVisible(currUnitPosition, unitVisibilityDistance);
    }

    // make areas around own cities complete-visible
    Iterator<Long> cityIterator = nationReader.getAllCities(nation.getID());
    while (cityIterator.hasNext()) {
      Long currCityID = cityIterator.next();
      Coordinate currCityPosition = cityReader.getCityPosition(currCityID);
      makeCompleteVisible(currCityPosition, cityVisibilityDistance);
    }
  }
View Full Code Here

      Messages.getMessages().err("MoveUnitsRelativeAction", "CivQuest will abort now!");
      System.exit(-1);
      // Otherwise the compiler complains
      return null;
    } else if (direction.equals("north-west")) {
      return new Coordinate(-1, 0);
    } else if (direction.equals("north")) {
      return new Coordinate(-1, -1);
    } else if (direction.equals("north-east")) {
      return new Coordinate(0, -1);
    } else if (direction.equals("east")) {
      return new Coordinate(1, -1);
    } else if (direction.equals("south-east")) {
      return new Coordinate(1, 0);
    } else if (direction.equals("south")) {
      return new Coordinate(1, 1);
    } else if (direction.equals("south-west")) {
      return new Coordinate(0, 1);
    } else if (direction.equals("west")) {
      return new Coordinate(-1, 1);
    } else {
      Messages.getMessages().err("MoveUnitsRelativeAction",
                     "Unknown value for parameter direction: " + direction);
      Messages.getMessages().err("MoveUnitsRelativeAction", "CivQuest will abort now!");
      System.exit(-1);
View Full Code Here

      for (int y = pos.y - visDistance; y <= pos.y + visDistance; y++) {
        if (mapData.isOnMap(x,y)) {
          // everything which is on map is inside the array, so no
          // test for the array-bounds should be required

          makeCompleteVisible(new Coordinate(x, y));
        }

      }
    }
  }
View Full Code Here

  void removeOwnUnit(Long id) {
    System.out.println("Removing (own) unit " + id + " from BWVManager for "
               + getNationID());
   
    visibleUnits.remove(id);
    Coordinate whereWasIt = Game.getMapData().getMapObjectPosition(id);
    fallBackIfNoOneThere(whereWasIt, getUnitVisDistance(), id, null);
  }
View Full Code Here

    visibleCities.put(id, null);
  }

  void removeOwnCity(Long id) {
    visibleCities.remove(id);
    Coordinate whereWasIt = Game.getMapData().getCityPosition(id);
    fallBackIfNoOneThere(whereWasIt, getCityVisDistance(), null, id);
  }
View Full Code Here

  private void fallBackIfNoOneThere(Set<Coordinate> fallBackSet,
                    Long notThisUnit, Long notThisCity) {
    // remove all fields which are complete-visible for other reasons
    Iterator<Coordinate> iterator = fallBackSet.iterator();
    while (iterator.hasNext()) {
      Coordinate currPos = iterator.next();
      Long unitProvidingVisibility = getUnitProvidingVisibility(currPos, notThisUnit);
      Long cityProvidingVisibility = getCityProvidingVisibility(currPos, notThisCity);

      if (unitProvidingVisibility != null
        || cityProvidingVisibility != null) {
View Full Code Here


 
    public Coordinate getScrollSize() {
    MapData mapData = Game.getMapData();   
        return new Coordinate(mapData.getMapWidth() * cellWidth, mapData.getMapHeight() * cellHeight);
    }
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.