Package civquest.map

Examples of civquest.map.Field


        if (this.scenarioEditor.getSelectedTab() == VEGETATION_TAB) {

            //only proceed if the vegetationTab is selected
            try {
                String paintSize = this.scenarioEditor.getSelectedPaintSize();
                Field field = this.map.getWorkingField();
                if (field == null) {
                    return;
                }
                Field.Height height = Field.getHeightConstant(
                        this.scenarioEditor.getSelectedHeight());
View Full Code Here


      for (int c = 0; c<points; c++)
    via[c] = getRandomSeaCoordinate();
  }

  private void setArea(Coordinate c, int x, int y){
      Field f = map.getField(c);
      for (int i = -1; i<2; i++)       
    if (map.isOnMap((c.x-(x*i)),(c.y-(y*i)))){
        if (i!=0){
      f = map.getField(c.x-(x*i),c.y-(y*i));
      f.setTemperature((f.getTemperature()+temperature)/2);
      //           f.setLayer(Field.LAYER_ROAD,"red");
      int temp = f.getTemperature();
      if (Util.getRandomNumber(3)==1){
          if (map.isOnMap((c.x+(x*2*i)),(c.y+(y*2*i)))){
        f = map.getField(c.x+(x*2*i),c.y+(y*2*i));
        f.setTemperature((f.getTemperature()+temp)/2);
        //        f.setLayer(Field.LAYER_ROAD,"red");
          }
      }
        }
    }
View Full Code Here

  public void actionPerformed(FunctionActionEvent e) {

    Point position = e.getPosition();

    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();
          if (activeNation != null) {
            ConstructCity newCityChange
              = new ConstructCity(field.getPosition(),
                        Game.getGame().getActiveNation());
            newCityChange.execute();

            SetPopulation setPopulation
              = new SetPopulation(field.getPosition(), 1000);
            setPopulation.execute();

            SetFieldRuledByCity change
              = new SetFieldRuledByCity(field.getPosition(),
                            newCityChange.getCity(),
                            false);
            change.execute();           
          } else {
            Messages.getMessages().info("ConstructTestCity", "QMapWarn",
View Full Code Here

        }
    }
  }

  private void heatArea(Coordinate from, Coordinate c, int temperature){     
      Field f = map.getField(c);    
      f.setTemperature((f.getTemperature()+temperature)/2);
      //      f.setLayer(Field.LAYER_ROAD,"red");
      temperature = f.getTemperature();
      if (((c.y>from.y) && (c.x==from.x)) || ((c.y>from.y) && (c.x>from.x))){
    setArea(c,1,0);
      } else
    if (((c.x>from.x) && (c.y==from.y)) || ((c.x<from.x) && (c.y<from.y))){
        setArea(c,0,1);
View Full Code Here

  public PrecipitationMap(MapData map){
      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);
      int temp = f.getTemperature();
      int dfc = f.getDistanceToCoast();     
      Field.Height hl = f.getHeightLevel();

      // made it a constant as it doesn't work that well anyway and I didn't want to
      // rewrite distanceFromHeightLevel (Wolfgang 2005-08-05)
      int nm = 2;
//       int nm = map.distanceFromHeightLevel(2, f.getPosition(), 4, 1); 
      double ice = 1.0;
      int[] table = temperatures(-35,40,10);
      for (int i = 0; i<10; i++)
          if (temp<=table[i]){
        ice = ((double)(i+1))/10;
        break;
          }
      double cf = 1.0;
      double of = 1.0;
      if (hl.isLand()){
          cf = 1-(dfc/10);
          if ((nm!=-1) && (nm>0))
        of = 1.0+((double)4-dfc)/10+((double)4-nm)/10;
      }     
      int rain = (int)(average * ice * cf * of);   
      if (rain<200 || rain>3000)
      f.setHumidity(rain);
        }
       

    }
     
View Full Code Here

        Unit unit = Game.getMapData().getUnit(unitID);
    this.from = unit.getPosition();

    notifyBefore();

        Field toField = Game.getMapData().getField(to);
    Game.getMapData().moveMapObject(unit, toField);
//         Game.getMapData().setUnitPosition(unit, field);
    unit.setTime(newTime);

    notifyAfter();
View Full Code Here

    Iterator<ResourceEdge<FieldResourceProductionMapping, ? extends ResourceNodeManager>> edgeIterator
      = source.getOutEdgeIterator();
    while (edgeIterator.hasNext()) {
      ResourceEdge<FieldResourceProductionMapping, ? extends ResourceNodeManager> edge = edgeIterator.next();
      Field field = (Field)(edge.getDestNode().getManager());
      ResourceSet amount = producer.getResourceProduction(field.getPosition());
      change.add(edge.getID(), amount);
    }

    change.execute();
  }
View Full Code Here

    // Add an appropriate edge for each field owned by the given nation
    NationReader nationReader = game.getNationReader();
    Iterator<Long> nationFieldIterator = nationReader.getAllFields(nation.getID());
    while (nationFieldIterator.hasNext()) {
      Long fieldID = nationFieldIterator.next();
      Field field = Game.getMapData().getField(fieldID);
      processAddField(productionNode, field);
    }
  }
View Full Code Here

    notifyBefore();

    Game game = Game.getGame();
        Messages messages = Messages.getMessages();
        MapData mapData = Game.getMapData();
        Field field = mapData.getField(location);
        Nation nation = game.getNation(owner);

        Iterator<Unit> unitsIt = field.getUnitIterator();
        if (unitsIt.hasNext()) {
            Unit unit = unitsIt.next();
            if (!unit.getOwner().equals(nation)) {
                messages.err("ConstructUnit", "You try to build a unit " +
                        "on a field where another nation's unit is located.");
                return;
            }
        }
        if (field.getCityOnField() != null &&
                !field.getCityOnField().getOwner().equals(nation)) {
            messages.err("ConstructUnit", "You try to build a unit " +
            "on a field where another nation's city is located.");
            return;
        }
View Full Code Here

    if (attackInfo == null) {
      return false;
    } else {
      Attacking attacker = attackInfo.attacker;
      int time = attackInfo.time;
      Field target = attackInfo.target;

//       DamagableMapObject target = attackManager.getTarget(weapon, damagables);
//       Damage damage = weapon.getDamage();

      ShotResults shotResults = attacker.calculateAttack();
      Damage[] damages = shotResults.getDamage();
      for (Damage damage : damages) {
        List<GameChange> shotChanges = shotResults.getChanges();
        List<GameChange> receiveChanges = damageManager.damage(target, damage);
        List<GameChange> timeChanges = computeTimeChanges(attacker, time);

        if (attacker instanceof Unit) {
          UnitShot unitShot = new UnitShot(attacker.getID(), shotChanges,
                           damage, target.getPosition(),
                           damageManager, receiveChanges,
                           timeChanges);
          unitShot.execute();
        } else {
          assert false : "Not yet implemented!";
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.