Package civquest.util

Examples of civquest.util.Coordinate


  }

  private void process(ConstructUnit constructUnit, boolean before, boolean after) {
    Long ownerID = constructUnit.getOwner();
    Long unitID = constructUnit.getUnitID();
    Coordinate location = constructUnit.getLocation();
    if (manager.getNationID().equals(ownerID)) {
      if (after) {
        manager.addOwnUnit(unitID, location);
      }
      constructUnit.notify(manager.getRestrictedToNation(), before, after);     
View Full Code Here


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

    process(constructCity, false, true);
  }

  private void process(ConstructCity constructCity, boolean before, boolean after) {
    Long cityID = constructCity.getCity();
    Coordinate location = constructCity.getLocation();
    Long ownerID = constructCity.getOwner();
    if (manager.getNationID().equals(ownerID)) {
      if (after) {
        manager.addOwnCity(cityID, location);
      }
View Full Code Here

  }

  public void beforeGameChanged(FieldChange fieldChange) {
    Long[] fieldIDs = fieldChange.getFields();
    for (Long fieldID : fieldIDs) {
      Coordinate pos = manager.getFieldReader().getFieldPosition(fieldID);
      if (manager.isCompleteVisible(pos)) {
        fieldChange.notifyBefore(manager.getRestrictedToNation());
      }
    }
  }
View Full Code Here

  }

  public void afterGameChanged(FieldChange fieldChange) {
    Long[] fieldIDs = fieldChange.getFields();
    for (Long fieldID : fieldIDs) {
      Coordinate pos = manager.getFieldReader().getFieldPosition(fieldID);
      if (manager.isCompleteVisible(pos)) {
        fieldChange.notifyAfter(manager.getRestrictedToNation());
      }
    }
  } 
View Full Code Here

            y = -1;
            x = evenY? -1 : 0;
            break;

        }
        return new Coordinate(from.x + x, from.y + y);
    }
View Full Code Here

        xString = suffix.substring(0, xEnd);
        yString = suffix.substring(xEnd + 1);
        try {
          int x = Integer.parseInt(xString);
          int y = Integer.parseInt(yString);
          return new Coordinate(x, y);
        } catch (NumberFormatException e) {
          String msg = "According to the prefix, we parse a Coordinate value. "
            + "Our suffix contains a separator, but either x or y is no number. "
            + "(I expect: x_y).";
          throw new AttributeSyntaxException(whereAreWe, currAttribute, msg);
View Full Code Here

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

    ConstructCity constructCity = new ConstructCity(new Coordinate(x, y),
                            nation);
    constructCity.execute();

    SetPopulation setPopulation
      = new SetPopulation(new Coordinate(x, y), 1000);
    setPopulation.execute();

    SetFieldRuledByCity change
      = new SetFieldRuledByCity(new Coordinate(x, y),
                    constructCity.getCity(), false);
    change.execute();
  }
View Full Code Here

                      GameDataAccessor gameData,
                      Coordinate to) {
    Set<MovePath> retPaths = new HashSet<MovePath>();
    for (Set<Long> group : unitGroups) {
      Long aUnit = group.iterator().next();
       Coordinate from = gameData.getMapObjectReader().getMapObjectPosition(aUnit);
      if (!from.equals(to)) {
        Messages.getMessages().info("MoveCalc", "DMCalcDec",
                      "From " + from + " to " + to);
        MovePath retPath
          = calculateOneMovePath(gameData,
                       group.toArray(new Long[0]),
View Full Code Here

                           Set<Long> units) {
    Map<Coordinate, Set<Long>> coordToGroup
      = new HashMap<Coordinate, Set<Long>>();
    MapObjectReader moReader = data.getMapObjectReader();
    for (Long unit : units) {
      Coordinate pos = moReader.getMapObjectPosition(unit);
      if (!coordToGroup.containsKey(pos)) {
        coordToGroup.put(pos, new HashSet<Long>());
      }
      coordToGroup.get(pos).add(unit);
    }
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.