Package civquest.util

Examples of civquest.util.Coordinate


    public void afterGameChanged(MarkField change) {
        Field markedField = Game.getMapData().getField(change.getFields()[0]);
       
        if (markedField != null) {
            FieldReader fieldReader = gameData.getFieldReader();
            Coordinate lmfPosition = markedField.getPosition();
            String vegName = fieldReader.getVegetationName(lmfPosition)
                .toLowerCase();

            setSelectedButton(this.vegetationButtons, vegName);
View Full Code Here


        MapData mapData = Game.getMapData();
       
        Iterator<Coordinate> mfit = this.mainMapView.getActiveGroup()
            .getFieldIterator();
        for (;mfit.hasNext();) {
            Coordinate coord = mfit.next();
            Field field = mapData.getField(coord);
            field.setHeightLevel(Field.getHeightConstant(height));
            try {
                field.setValues(new VegetationData(
                        this.registry, vegName), -1, -1);
View Full Code Here

   *          the map.
   */
  public abstract Coordinate adjustArrayCoordToScrolling(Coordinate coord);

  public Coordinate adjustArrayCoordToScrolling(int x, int y) {
      return adjustArrayCoordToScrolling(new Coordinate(x, y));
  }
View Full Code Here

  /** Transforms the given absolute paint-coordinate into an unscrolled array-coordinate.
   */
  public abstract Coordinate getUnscrolledArrayCoord(Coordinate paintCoord);

  public Coordinate getUnscrolledArrayCoord(int x,int y) {
      return getUnscrolledArrayCoord(new Coordinate(x,y));
  }
View Full Code Here

  public Coordinate[] getAbsFieldEdgeCoords(Coordinate pos, Coordinate offset) {
    assert offset.equals(0, -1) || offset.equals(1, 0)
      || offset.equals(0, 1) || offset.equals(-1, 0);

    if (offset.equals(0, -1)) {
      return new Coordinate[] {getFieldCornerOffset(pos, new Coordinate(-1, -1)),
                   getFieldCornerOffset(pos, new Coordinate(1, -1))};
    } else if (offset.equals(1, 0)) {
      return new Coordinate[] {getFieldCornerOffset(pos, new Coordinate(1, -1)),
                   getFieldCornerOffset(pos, new Coordinate(1, 1))};
    } else if (offset.equals(0, 1)) {
      return new Coordinate[] {getFieldCornerOffset(pos, new Coordinate(1, 1)),
                   getFieldCornerOffset(pos, new Coordinate(-1, 1))};
    } else if (offset.equals(-1, 0)) {
      return new Coordinate[] {getFieldCornerOffset(pos, new Coordinate(-1, 1)),
                   getFieldCornerOffset(pos, new Coordinate(-1, -1))};
    } else {
      throw new IllegalArgumentException("Illegal offset");
    }
  }
View Full Code Here

    {
    public Field startRiver()
    {
      for(int z = 0;z < config.rprstarter_starttries;z++)
        {
          Coordinate coord = mapdata.getRandomCoordinate();
          Field retvalue = mapdata.getField(coord);
          if(retvalue.getWaterFlow() < 0)
            {
              Field[] coasts = mapdata.getCoasts(coord);
              if((coasts != null) && (coasts.length > 0))
View Full Code Here

    Messages messages = Messages.getMessages();

    if (quadMap.setWFByMouse()) {
      Field pointedField = quadMap.getFieldAtPosition(e.getPosition());
      if (pointedField != quadMap.getWorkingField()) {
        Coordinate pos = null;
        if (pointedField != null) {
          pos = pointedField.getPosition();
        }
       
        SetWorkingField setWFChange = new SetWorkingField(quadMap, pos);
View Full Code Here

    public int evolveRiver(Field start) {startpos = start.getPosition();return evolveRiver(start,0,1);}
    /** Performs the calculations described above. */
    private int evolveRiver(Field start,int stoppoints,int depth)
    { 
      start.setWaterFlow(start.getHumidity());
      Coordinate thiscoord = start.getPosition();
      if(stop(stoppoints))
        return start.getHumidity();
      int otherfieldsflow = 0;
      Coordinate[] nextcoord = new Coordinate[4];
      int[] flowdirections = new int[4];
      int[] antiflowdirections = new int[4];
      for(int n = 0;n < 4;n++)
        {
          nextcoord[n] = null;
          flowdirections[n] = antiflowdirections[n] = Direction.UNDEFINED;       
        }
      for(int n = 0;n < 4;n++)
        {
          int currindex = 0;
          while(true)
            {
              currindex = randomgen.nextInt(4);
              if(nextcoord[currindex] == null)
                break;
            }
          switch(n)
            {
            case 0: nextcoord[currindex] = thiscoord.add(north);
              break;                                       
            case 1: nextcoord[currindex] = thiscoord.add(east);
              break;
            case 2: nextcoord[currindex] = thiscoord.add(south);
              break;
            case 3: nextcoord[currindex] = thiscoord.add(west);
            }
        }
      int recnumber = 0;
      for(int n = 0;n < 4;n++)
        {
          nextcoord[n] = mapdata.adjustToMapSize(nextcoord[n]);
          if(nextcoord[n] != null)
            {
              Field nextfield = mapdata.getField(nextcoord[n]);
              if((nextfield.getWaterFlow() < 0) && (nextfield.isLand()))
                {
                  int probability = -1;
                  int from = config.UNDEFINED;
                  int to = config.UNDEFINED;
                  from = config.getHeightConstant(start);
                  to = config.getHeightConstant(nextfield);
                  if((from != config.UNDEFINED) && (to != config.UNDEFINED)
                     && (randomgen.nextDouble() < config.probevprobs[from][to]))
                    {
                      if(config.probev_seastopprobsuse)
                        {
                          int nextdst = nextfield.getDistanceToSea();
                          double [] probs = config.probev_seastopprobs;
                          int [] mindepth = config.probev_seastopprobsmindepth;
                          if((nextdst <= probs.length)
                             && (depth >= mindepth[nextdst - 1])
                             && (randomgen.nextDouble() <= probs[nextdst - 1]))
                            continue;
                        }
                      int nstoppoints = stoppoints +
                        config.probev_callstoppoints[recnumber];
                      if(config.probev_spforturnarounduse)
                        {               
                          Coordinate s = start.getPosition();
                          int dst = Math.abs(startpos.x - nextcoord[n].x) +
                            Math.abs(startpos.y - nextcoord[n].y);
                          int olddst = Math.abs(startpos.x - s.x) +
                            Math.abs(startpos.y - s.y);
                          if((dst < olddst)
View Full Code Here

    }

    public void actionPerformed(FunctionActionEvent e) {
        if (this.map.getGameData() != null) {
            Group group = this.map.getActiveGroup();
            Coordinate wf = this.map.getWorkingFieldPos();
            int x = wf.x;
            int y = wf.y;
           
            Vector<Coordinate> coords = new Vector();
            Vector<Coordinate> temp = new Vector();
           
            //no loop here because I want to change the order a bit...
            temp.add(new Coordinate(x-1, y-1));
            temp.add(new Coordinate(x, y-1));
            temp.add(new Coordinate(x+1, y-1));
            temp.add(new Coordinate(x-1, y));
            temp.add(new Coordinate(x+1, y));
            temp.add(new Coordinate(x-1, y+1));
            temp.add(new Coordinate(x, y+1));
            temp.add(new Coordinate(x+1, y+1));
            temp.add(wf);

            MapData mapData = Game.getMapData();
            for (int i = 0; i < temp.size(); i++) {
                Coordinate coord = temp.get(i);
                if (mapData.isOnMap(coord)) {
                    coords.add(coord);
                }
            }
            Long[] fieldIDs = new Long[temp.size()];
View Full Code Here

   * @return id of a unit as described
   */
  Long getUnitProvidingVisibility(Coordinate pos, Long notThisOne) {
    Iterator iterator = Game.getMapData().getRectIterator(pos, getUnitVisDistance());
    while (iterator.hasNext()) {
      Coordinate checkPos = (Coordinate)(iterator.next());

      // BWVMs own readers!
      FieldReader fieldReader = getFieldReader();
      MapObjectReader moReader = getMapObjectReader();
      if (fieldReader.areUnitsAvailable(checkPos)) {
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.