Package civquest.map

Examples of civquest.map.CityReader


  }

  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))
          && (!(cityID.equals(notThisOne)))) {
          return cityID;
        }
      }
    }
View Full Code Here


      }     
    }

    Game game = Game.getGame();
    MapObjectReader moReader = game.getMapObjectReader();
    CityReader cityReader = game.getCityReader();
    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

    if (position != null) {
      Field field = quadMap.getFieldAtPosition(position);
   
      if (field != null) {
        GameDataAccessor gameData = quadMap.getGameData();
        CityReader cityReader = gameData.getCityReader();
        if (cityReader.isCityIDAvailable(field.getPosition())
          && cityReader.getCityID(field.getPosition()) != null) {
          Messages messages = Messages.getMessages();
          messages.info("ConstructTestCityAction", "CityAR",
                  "You can't build more than one city on a field!");
        } else {
          Nation activeNation = Game.getGame().getActiveNation();
View Full Code Here

  /** 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)) {
View Full Code Here

  /********************************* Change of display-nation **************/

  private void scrollToStartPosition(GameDataAccessor gameData) {
    RestrictedToNation resToNation = gameData.getRestrictedToNation();
    CityReader cityReader = gameData.getCityReader();
    NationReader nationReader = gameData.getNationReader();

    Iterator<Long> iterator;
    if (resToNation.isInAllNationsMode()) {
      iterator = null;
    } else if (resToNation.isInSpecificNationsMode()) {
      Long[] forNations = resToNation.getForNations();
      if (forNations.length > 0) {
        iterator = nationReader.getAllCities(forNations[0]);
      } else {
        iterator = null;
      }
    } else {
      // Should not happen
      iterator = null;
    }

    if (iterator != null && iterator.hasNext()) {
      Long aCityID = iterator.next();
      Coordinate aCityPos
        = cityReader.getCityPosition(aCityID);
      center(aCityPos);
    } else {
      MapData mapData = Game.getMapData();
      Coordinate centerPos = new Coordinate(mapData.getArrayWidth() / 2,
                          mapData.getArrayHeight() / 2);
View Full Code Here

  public void afterGameChanged(CityChange cityChange) {
    process(cityChange);
 

  private void process(CityChange cityChange) {
    CityReader cityReader = gameData.getCityReader();

    Long[] ids = cityChange.getCities();
    for (int n = 0; n < ids.length; n++) {
      if (ids[n] >= 0) {
        Coordinate position = cityReader.getCityPosition(ids[n]);
        if (position != null) {
          fieldViews[position.x][position.y].dataChanged();
        }
      }
    }
View Full Code Here

  public Coordinate getPaintSize() {
    return size;
  }

  public int getInformationScore() {
    CityReader cityReader = gameData.getCityReader();
   
    if (!cityReader.isCityIDAvailable(position)) {
      return 0;
    } else {
      return 100;
    }
  }
View Full Code Here

  }

  private void updateImage() {
    // For now...

    CityReader cityReader = gameData.getCityReader();
    if (cityReader.isCityIDAvailable(position)
      && cityReader.getCityID(position) != null) {
      cityImage = layCityImageSet.getImage("Village");
   
   
      if (cityImage == null) {
        Messages messages = Messages.getMessages();
View Full Code Here

TOP

Related Classes of civquest.map.CityReader

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.