Package civquest.map

Examples of civquest.map.MapObjectReader


    while (iterator.hasNext()) {
      Coordinate checkPos = (Coordinate)(iterator.next());

      // BWVMs own readers!
      FieldReader fieldReader = getFieldReader();
      MapObjectReader moReader = getMapObjectReader();
      if (fieldReader.areUnitsAvailable(checkPos)) {
        Iterator<Long> unitIterator = fieldReader.getUnits(checkPos);
        while (unitIterator.hasNext()) {
          Long currID = unitIterator.next();
          if (moReader.isMapObjectOwnerAvailable(currID)
            && getNationID().equals(moReader.getMapObjectOwner(currID))
            && (!(currID.equals(notThisOne)))) {
            return currID;
          }
        }
      }
View Full Code Here


        visibilityLevels[x][y] = INVISIBLE;
      }     
    }

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

   * @param unitGroup unit-group, expected to be non-empty
   * @return position of the given unit-group as described
   */
  private Coordinate getPosition(Set<Long> unitGroup) {
    GameDataAccessor gameData = quadMap.getGameData();
    MapObjectReader moReader = gameData.getMapObjectReader();
    Long aUnit = unitGroup.iterator().next();
    return moReader.getMapObjectPosition(aUnit);
  }
View Full Code Here

   * @return do we know a speed to the given field?
   * @throws InformationNotAvailableException
   */
  public static boolean isSpeedKnown(GameDataAccessor gameData,
                     Long moving, Coordinate to) {
    MapObjectReader moReader = gameData.getMapObjectReader();
    if (moReader.isMoving(moving)) {
      return moReader.getAsMoving(moving).isSpeedAvailable(to);
    } else {
      throw new ClassCastException("MovementRules.isSpeedKnown expects "
                     + "a Moving-id");
    }
  }
View Full Code Here

    }
  }

  private static Long getOwner(GameDataAccessor gameData, Set<Long> attIDs) {
    Long owner = null;
    MapObjectReader moReader = gameData.getMapObjectReader();
   
    for (Long attID : attIDs) {
      if (moReader.isMapObjectOwnerAvailable(attID)) {
        Long newOwner = moReader.getMapObjectOwner(attID);
        if (owner == null) {
          owner = newOwner;
        } else {
          assert owner.equals(newOwner) : "All Attackings must have the same owner!";
        }
View Full Code Here

   *  is specified by the given game-data.
   */
  private static boolean containsForeignTargets(GameDataAccessor gameData,
                          Long owner, Coordinate pos) {
    FieldReader fieldReader = gameData.getFieldReader();
    MapObjectReader moReader = gameData.getMapObjectReader();

    if (!fieldReader.areUnitsAvailable(pos) || owner == null) {
      return false;
    } else {
      Iterator<Long> unitIterator = fieldReader.getUnits(pos);
      while (unitIterator.hasNext()) {
        Long currUnit = unitIterator.next();
        if (moReader.isMapObjectOwnerAvailable(currUnit)) {
          Long foreignOwner = moReader.getMapObjectOwner(currUnit);
          if (!(owner.equals(foreignOwner))) {
            return true;
          }
        }
      }
View Full Code Here

            g.drawString("Remaining time not known", x, y);
        }      
    }

    private void drawHealth(Graphics g, Long unitID, int x, int y, int width) {
        MapObjectReader moReader = gameData.getMapObjectReader();
        if (moReader.isMapObjectHealthAvailable(unitID)) {
            double health = moReader.getMapObjectHealth(unitID);
            float healthPercentile = (float)(health);
            g.drawString("Health: " + (int)(healthPercentile * 100) + "%", x, y);

            int barX = x + 90;
            int barY = y - 8;
View Full Code Here

        g.drawRect(x, y, width, height);
    }

    private void drawDetailInformation(Graphics g, Long unitID,
                                       int x, int y, int width) {
        MapObjectReader moReader = gameData.getMapObjectReader();
        if (moReader.asMapObjectAvailable(unitID)) {
            MapObject mo = moReader.getAsMapObject(unitID);
            detailPainter.set(g, x, y, mo);
            try {
                detailCaller.callV(detailPainter, mo);
            } catch (MethodCallerException e) {
                Messages.getMessages().err("DetailedUnitInfoComponent", "Problem with "
View Full Code Here

   * @throws InformationNotAvailableException if the speed to the given
   *         field is not available
   */
  private static int getSpeedForMove(GameDataAccessor gameData,
                    Long mvID, Coordinate to) {
    MapObjectReader moReader = gameData.getMapObjectReader();
    return moReader.getAsMoving(mvID).getSpeed(to);   
  }
View Full Code Here

   * @param to destination field
   * @return speeds as described
   */
  public static int[] getSpeedForMove(GameDataAccessor gameData, Long[] movings,
                    Coordinate to) {
    MapObjectReader moReader = gameData.getMapObjectReader();
   
    Long owner = getOwner(gameData, movings);
    if (foreignStops(gameData, owner, to)) {
      return null;
    } else {
      int[] speeds = new int[movings.length];
      for (int n = 0; n < movings.length; n++) {
        if (moReader.isMoving(movings[n])) {
          speeds[n] = getSpeedForMove(gameData, movings[n], to);
          if (speeds[n] <= 0) {
            return null;
          }
        } else {
View Full Code Here

TOP

Related Classes of civquest.map.MapObjectReader

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.