Examples of MapObject


Examples of amidst.map.MapObject

          (mouse.y < widget.getY() + widget.getHeight())) {
          if (widget.onClick(mouse.x - widget.getX(), mouse.y - widget.getY()))
            return;
        }
      }
      MapObject object = worldMap.getObjectAt(mouse, 50.0);
     
      if (selectedObject != null)
        selectedObject.localScale = 1.0;

      if (object != null)
View Full Code Here

Examples of amidst.map.MapObject

  }
 
  @Override
  public void draw(Graphics2D g2d, float time) {
    if (targetVisibility) {
      MapObject selectedObject = mapViewer.getSelectedObject();
      message = selectedObject.getName() + " [" + selectedObject.rx + ", " + selectedObject.ry + "]";
      icon = selectedObject.getImage();
    }

    setWidth(45 + mapViewer.getFontMetrics().stringWidth(message));
    super.draw(g2d, time);
View Full Code Here

Examples of civquest.map.mapobj.MapObject

  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

Examples of civquest.map.mapobj.MapObject

    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

Examples of civquest.map.mapobj.MapObject

        RestrictedToNation resToNation = qMap.getGameData()
            .getRestrictedToNation();
        Iterator<MapObject> moit = mapObjects.iterator();
        for (;moit.hasNext();) {
            MapObject mapObject = moit.next();
            if (mapObject instanceof City) {
                RemoveCity remove = new RemoveCity(resToNation,
                        mapObject.getID());
                remove.execute();
            } else if (mapObject instanceof Unit) {
                RemoveUnit remove = new RemoveUnit(resToNation,
                        mapObject.getID());
                remove.execute();
            }
        }
        qMap.getFieldView(Game.getGame(), coordinate).dataChanged();
    }
View Full Code Here

Examples of civquest.map.mapobj.MapObject

           
            JPanel objectsPanel = new JPanel();
            objectsPanel.setLayout(new GridLayout(0, 1));
            for (int i = 0; i<mapObjects.size(); i++) {
                JPanel rowPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
                MapObject mo = this.mapObjects.get(i);
                this.checkBoxes.add(new JCheckBox());
                this.objectLabels.add(new JLabel(mo.getModelName()));

                rowPanel.add(this.checkBoxes.get(i));
                rowPanel.add(this.objectLabels.get(i));
                objectsPanel.add(rowPanel);
            }
View Full Code Here

Examples of civquest.map.mapobj.MapObject

      = loadedData.getLoadedDataHashSet("mapObjects");
    for (LoadedData moLoadedData : moLoadedDataSet) {
      String modelName
        = moLoadedData.getString(MapObject.MODEL_NAME_KEY);

      MapObject newMapObject = null;
      // hack to make it run - TODO: think about a more elegant way of
      // mapping model names to the appropriate constructor call
      if (modelName.equals("units_musketeer")) {
        newMapObject = new Musketeer(moLoadedData, step);
      } else if (modelName.equals("city")) {
        newMapObject = new City(moLoadedData, step);
      }
      mapObjects.add(newMapObject);
      newMapObject.setField(this);
    }
  } 
View Full Code Here

Examples of civquest.map.mapobj.MapObject

    public void execute() {
        notifyBefore();

        Iterator<MapObject> moit = mapObjects.iterator();
        for (;moit.hasNext();) {
            MapObject mapObject = moit.next();
            if (mapObject instanceof City) {
                RemoveCity remove = new RemoveCity(this.map.getGameData().getRestrictedToNation(), mapObject.getID());
                remove.execute();
            } else if (mapObject instanceof Unit) {
                RemoveUnit remove = new RemoveUnit(this.map.getGameData().getRestrictedToNation(), mapObject.getID());
                remove.execute();
            }
        }
        notifyAfter();
        try {
View Full Code Here

Examples of com.badlogic.gdx.maps.MapObject

    }
  }

  protected void loadObject (MapLayer layer, Element element) {
    if (element.getName().equals("object")) {
      MapObject object = null;

      float scaleX = convertObjectToTileSpace ? 1.0f / mapTileWidth : 1.0f;
      float scaleY = convertObjectToTileSpace ? 1.0f / mapTileHeight : 1.0f;

      float x = element.getFloatAttribute("x", 0) * scaleX;
      float y = (mapHeightInPixels - element.getFloatAttribute("y", 0)) * scaleY;

      float width = element.getFloatAttribute("width", 0) * scaleX;
      float height = element.getFloatAttribute("height", 0) * scaleY;

      if (element.getChildCount() > 0) {
        Element child = null;
        if ((child = element.getChildByName("polygon")) != null) {
          String[] points = child.getAttribute("points").split(" ");
          float[] vertices = new float[points.length * 2];
          for (int i = 0; i < points.length; i++) {
            String[] point = points[i].split(",");
            vertices[i * 2] = Float.parseFloat(point[0]) * scaleX;
            vertices[i * 2 + 1] = -Float.parseFloat(point[1]) * scaleY;
          }
          Polygon polygon = new Polygon(vertices);
          polygon.setPosition(x, y);
          object = new PolygonMapObject(polygon);
        } else if ((child = element.getChildByName("polyline")) != null) {
          String[] points = child.getAttribute("points").split(" ");
          float[] vertices = new float[points.length * 2];
          for (int i = 0; i < points.length; i++) {
            String[] point = points[i].split(",");
            vertices[i * 2] = Float.parseFloat(point[0]) * scaleX;
            vertices[i * 2 + 1] = -Float.parseFloat(point[1]) * scaleY;
          }
          Polyline polyline = new Polyline(vertices);
          polyline.setPosition(x, y);
          object = new PolylineMapObject(polyline);
        } else if ((child = element.getChildByName("ellipse")) != null) {
          object = new EllipseMapObject(x, y - height, width, height);
        }
      }
      if (object == null) {
        object = new RectangleMapObject(x, y - height, width, height);
      }
      object.setName(element.getAttribute("name", null));
      String rotation = element.getAttribute("rotation", null);
      if (rotation != null) {
        object.getProperties().put("rotation", Float.parseFloat(rotation));
      }
      String type = element.getAttribute("type", null);
      if (type != null) {
        object.getProperties().put("type", type);
      }
      int gid = element.getIntAttribute("gid", -1);
      if (gid != -1) {
        object.getProperties().put("gid", gid);
      }
      object.getProperties().put("x", x * scaleX);
      object.getProperties().put("y", (y - height) * scaleY);
      object.setVisible(element.getIntAttribute("visible", 1) == 1);
      Element properties = element.getChildByName("properties");
      if (properties != null) {
        loadProperties(object.getProperties(), properties);
      }
      layer.getObjects().add(object);
    }
  }
View Full Code Here

Examples of com.badlogic.gdx.maps.MapObject

    }
  }

  protected void loadObject (MapLayer layer, Element element) {
    if (element.getName().equals("object")) {
      MapObject object = null;

      float scaleX = convertObjectToTileSpace ? 1.0f / mapTileWidth : 1.0f;
      float scaleY = convertObjectToTileSpace ? 1.0f / mapTileHeight : 1.0f;

      float x = element.getFloatAttribute("x", 0) * scaleX;
      float y = (mapHeightInPixels - element.getFloatAttribute("y", 0)) * scaleY;

      float width = element.getFloatAttribute("width", 0) * scaleX;
      float height = element.getFloatAttribute("height", 0) * scaleY;

      if (element.getChildCount() > 0) {
        Element child = null;
        if ((child = element.getChildByName("polygon")) != null) {
          String[] points = child.getAttribute("points").split(" ");
          float[] vertices = new float[points.length * 2];
          for (int i = 0; i < points.length; i++) {
            String[] point = points[i].split(",");
            vertices[i * 2] = Float.parseFloat(point[0]) * scaleX;
            vertices[i * 2 + 1] = -Float.parseFloat(point[1]) * scaleY;
          }
          Polygon polygon = new Polygon(vertices);
          polygon.setPosition(x, y);
          object = new PolygonMapObject(polygon);
        } else if ((child = element.getChildByName("polyline")) != null) {
          String[] points = child.getAttribute("points").split(" ");
          float[] vertices = new float[points.length * 2];
          for (int i = 0; i < points.length; i++) {
            String[] point = points[i].split(",");
            vertices[i * 2] = Float.parseFloat(point[0]) * scaleX;
            vertices[i * 2 + 1] = -Float.parseFloat(point[1]) * scaleY;
          }
          Polyline polyline = new Polyline(vertices);
          polyline.setPosition(x, y);
          object = new PolylineMapObject(polyline);
        } else if ((child = element.getChildByName("ellipse")) != null) {
          object = new EllipseMapObject(x, y - height, width, height);
        }
      }
      if (object == null) {
        object = new RectangleMapObject(x, y - height, width, height);
      }
      object.setName(element.getAttribute("name", null));
      String type = element.getAttribute("type", null);
      if (type != null) {
        object.getProperties().put("type", type);
      }
      int gid = element.getIntAttribute("gid", -1);
      if (gid != -1) {
        object.getProperties().put("gid", gid);
      }
      object.getProperties().put("x", x * scaleX);
      object.getProperties().put("y", (y - height) * scaleY);
      object.setVisible(element.getIntAttribute("visible", 1) == 1);
      Element properties = element.getChildByName("properties");
      if (properties != null) {
        loadProperties(object.getProperties(), properties);
      }
      layer.getObjects().add(object);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.