Package civquest.map

Examples of civquest.map.Field


        for(int y = 0;y < height;y++){

            for(int x = 0; x < width;x++)
    if(mapData.isArrayCoordOnMap(x,y))
        {
                    Field f = mapData.getField(x,y);
                    /*                    if(f.isNormalSea() || f.isShallowSea())
                        f.setLayer(Field.LAYER_GROUND, "Ocean");
                    else
                        if (f.getHeightLevel()>2)
                            f.setLayer(Field.LAYER_GROUND, "Mountain");
                    else
                        f.setLayer(Field.LAYER_GROUND, "Grass");
                    */                   
        if(f.isSea())
                        f.setValues(ocean,Field.LAYER_GROUND,mapType);                   
                    else                                           
                        f.setValues(grass,Field.LAYER_GROUND,mapType);                   
                   
                    //      f.setLayer(Field.LAYER_GROUND,grass.getRandomTile(mapType,f.getHeightLevel()-1));
                   
        /*
         if(f.isNormalSea() || f.isShallowSea())
View Full Code Here


      for(int y = 0;y < mapdata.getArrayHeight();y++)
        if(mapdata.isArrayCoordOnMap(x,y))
          mapdata.getField(x,y).setWaterFlow(NOWATERFLOW); // The default value has to be negative
    for(int n = 0;n < config.firststeptries;n++)
      {
        Field startfield = riverstarter.startRiver();
        if(startfield == null)
          continue;
        riverevolver.evolveRiver(startfield);
      }
    rivercompleter.completeRivers();
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))
                {
                  retvalue.setWaterFlowTo(coasts[randomgen.nextInt(coasts.length)]);
                  return retvalue;
                }
            }
        }
      return null;
View Full Code Here

      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)
                             && (dst >= config.probev_turnaroundmindist))
                            nstoppoints += config.probev_spforturnaround;
                        }
             
                      if(config.probev_spfornearerseause)
                        {
                          int newseadist = nextfield.getDistanceToSea();
                          if((newseadist <= config.probev_nearerseamaxdist)
                             && (newseadist < start.getDistanceToSea()))
                            nstoppoints += config.probev_spfornearersea;
                        }
                      start.addWaterFlowFrom(nextfield);
                      nextfield.setWaterFlowTo(start);
                      otherfieldsflow += evolveRiver(nextfield,nstoppoints,depth + 1);
                      recnumber++;
                    }
                }
            }
View Full Code Here

  public void actionPerformed(FunctionActionEvent e) {
    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);
        setWFChange.execute();
      }     
View Full Code Here

      ArrayList<Field> updatefields = new ArrayList<Field>();
      for(int x = 0;x < mapdata.getArrayWidth();x++)
        for(int y = 0;y < mapdata.getArrayHeight();y++)
          if(mapdata.isArrayCoordOnMap(x,y))
            {
              Field field = mapdata.getField(x,y);
              if((field.getWaterFlow() == NOWATERFLOW) && (field.isLand())
                 && (!field.isLandVolcano()))
                {
                  if(!computeWaterFlow(field))
                    remainingfields.add(field);
                  else
                    {
                      updatefields.add(field);
                      d[x][y] = 1;
                    }
                }
            }
      for(int n = 0;n < updatefields.size();n++)
        {
          Field field = updatefields.get(n);
          field.setWaterFlow(field.getHumidity());
        }
      int k = 2;
      while(remainingfields.size() > 0)
        {
          int n = 0;
          updatefields = new ArrayList<Field>();
          while(n < remainingfields.size())
            if(computeWaterFlow(remainingfields.get(n)))
              updatefields.add(remainingfields.remove(n));
            else
              n++;
          if(updatefields.size() == 0)
            break;            // Remaining fields have no water-flow.
          for(int z = 0;z < updatefields.size();z++)
            {
              Field f = updatefields.get(z);
              f.setWaterFlow(f.getHumidity());
              d[f.getPosition().x][f.getPosition().y] = k;
            }
          k++;
        }
    }
View Full Code Here

      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]);
            if((f.isSea()) || (f.getWaterFlow() != NOWATERFLOW))
              numberofvalidcoords++;
            else
              validcoords[n] = null;     
          }
      Field[] retvalue = new Field[numberofvalidcoords];
View Full Code Here

    /* Air temperature */
    messages.info("ClimateGenerator", "CVGenState", "Setting climate")
    int map[][] = new AirTemperatureMap(this.mapData, this.mapType, polTemp, eqTemp, bands).getAirTemperatureMap();
    for (int x = 0; x<map.length; x++)
      for (int y = 0; y<map[0].length; y++){
        Field f = mapData.getField(mapData.mapCoordinate(new Coordinate(x,y)));
        if (f.isHills()) {
          f.setTemperature(map[x][y] - 20);
        } else if (f.isMountain()) {
          f.setTemperature(map[x][y] - 30);
        } else if (f.isHighMountain()) {
          f.setTemperature(map[x][y] - 40);
        } else {
          f.setTemperature(map[x][y]);
        }

//         if (f.isLand() && !(f.isPlain()))
//           f.setTemperature(map[x][y]-(f.getHeightLevel()*10));
//         else
View Full Code Here

    private boolean hasNeighbour(Coordinate c, String name, int layer){
  for (int x = -1; x<2; x++)
      for (int y = -1; y<2; y++)
    if (mapData.isOnMap(c.x-x,c.y-y)){
        if (x!=0 || y!=0){
      Field f = mapData.getField(c.x-x,c.y-y);
       String fname = f.getName(layer);
       if (fname!=null)
           if (fname.toUpperCase().equals(name))
         return true;         
         }
    }
View Full Code Here

    private void generateLandscape(){
  for(int x = 0; x < width;x++)
      for(int y = 0;y < height;y++){
    if(mapData.isArrayCoordOnMap(x,y))
        {
      Field f = mapData.getField(x,y);      
      if(f.isSea())
          f.setValues(ocean,Field.LAYER_GROUND,mapType);                   
      else
          f.setValues(land,Field.LAYER_GROUND,mapType);                   
     
        }
      }   
 
  for(int x = 0; x < width;x++)
      for(int y = 0;y < height;y++){
    if(mapData.isArrayCoordOnMap(x,y)){       
                    Field f = mapData.getField(x,y);
        if (!f.isSea()){
      int h = f.getHumidity();
      int t = f.getTemperature();
      for (int i = 0; i<groundData.size(); i++){
          VegetationData w = (VegetationData)groundData.get(i);         
          SimpleConditionParser parse = new SimpleConditionParser(((VegetationData)groundData.get(i)).getCondition());
          parse.setH(h);
          parse.setT(t);
          if (parse.eval()){
        int prob = getProbability(w,new Coordinate(x,y), Field.LAYER_TERRAIN);
        if ((Util.getRandomNumber(10)+1)<=prob && (prob>0))
            f.setValues(w,Field.LAYER_GROUND,mapType);
          }         
      }
      for (int i = 0; i<terrainData.size(); i++){
          VegetationData w = (VegetationData)terrainData.get(i);         
          SimpleConditionParser parse = new SimpleConditionParser(w.getCondition());         
          parse.setH(h);
          parse.setT(t);
          if (parse.eval()){
        int prob = getProbability(w,new Coordinate(x,y), Field.LAYER_TERRAIN);
        if ((Util.getRandomNumber(10)+1)<=prob && (prob>0))
            f.setValues(w,Field.LAYER_TERRAIN,mapType);
          }
         
      }
        }
    }           
View Full Code Here

TOP

Related Classes of civquest.map.Field

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.