/** * Checks two map coordiantes if they are on the map. * * @param x * The y coordinate in map space. * @param y * The x coordinate in map space. * @return If the map coordinates are on the map. */ public boolean checkMapCoordinates(int x, int y) { return x >= 0 && x < this.map.getWidth() && y >= 0 && y < this.map.getHeight(); }
public int getHeight(int x, int y) { if (x >= 0 && x < map.getWidth() && y >= 0 && y < map.getHeight()) { return map.getHeightAt(x, y); } else { return 0; } }
/** * Gets the landscape at a given position. * * @param x * x * @param y * y * @return The landscape type. */ public ELandscapeType getLandscape(int x, int y) { return map.getLandscapeTypeAt(x, y); }
for (int x = mapminX; x < mapmaxX && (displayOccupied != OccupiedAreaMode.NONE || displayBuildings || displaySettlers != SettlersMode.NONE); x++) { boolean visible = map.getVisibleStatus(x, y) > CommonConstants.FOG_OF_WAR_EXPLORED; if (visible && displaySettlers != SettlersMode.NONE) { IMovable settler = map.getMovableAt(x, y); if (settler != null && (displaySettlers == SettlersMode.ALL || settler.getMovableType().isPlayerControllable())) { settlerColor = context.getPlayerColor(settler.getPlayer().getPlayerId()).toShortColor(1); IMapObject object = map.getMapObjectsAt(x, y); IBuilding building = (object != null) ? (IBuilding) object.getMapObject(EMapObjectType.BUILDING) : null; if (map.isBorder(x, y)) { byte player = map.getPlayerIdAt(x, y); Color playerColor = context.getPlayerColor(player); occupiedColor = playerColor.toShortColor(1); byte player = map.getPlayerIdAt(x, y); if (player >= 0 && !map.getLandscapeTypeAt(x, y).isBlocking) { Color playerColor = context.getPlayerColor(player); if (map.isBuilding(x, y)) { buildingColor = BLACK;
final short mapWidth = map.getWidth(); final short mapHeight = map.getHeight(); byte visibleStatus = map.getVisibleStatus(centerX, centerY); if (visibleStatus > CommonConstants.FOG_OF_WAR_EXPLORED) { color = getSettlerForArea(map, context, mapMinX, mapMinY, mapMaxX, mapMaxY); int dheight = map.getHeightAt(centerX, mapMinY) - map.getHeightAt(centerX, Math.min(mapMinY + mapLineHeight, mapHeight - 1)); basecolor *= 1 + .15f * dheight;
private void drawTile(int x, int y) { int tileIndex = x+y*width; IMapObject object = objectsGrid != null ? objectsGrid[tileIndex] : map.getMapObjectsAt(x, y); if (object != null) { this.objectDrawer.drawMapObject(x, y, object); object = objectsGrid != null ? objectsGrid[tileIndex-3*width] :map.getMapObjectsAt(x, y - 3); if (object != null && object.getObjectType() == EMapObjectType.BUILDING && ((IBuilding) object).getBuildingType() == EBuildingType.STOCK) { this.objectDrawer.drawStockFront(x, y - 3, (IBuilding) object); object = objectsGrid != null ? objectsGrid[tileIndex+3*width] : map.getMapObjectsAt(x, y + 3); if (object != null) { EMapObjectType type = object.getObjectType(); IMovable movable = movableGrid != null ? movableGrid[tileIndex] : map.getMovableAt(x, y); if (movable != null) { this.objectDrawer.draw(movable); if (borderGrid != null ? borderGrid.get(tileIndex) : map.isBorder(x, y)) { byte player = map.getPlayerIdAt(x, y); objectDrawer.drawPlayerBorderObject(x, y, player);
isVisibleGridAvailable = false; width = map.getWidth(); height = map.getHeight(); this.gameTimeProvider = game.getGameTimeProvider(); this.textDrawPosition = textDrawPosition; this.connector.addListener(this); map.setBackgroundListener(background);
private IMaterialDistributionSettings currentDistributionSettingsProvider(IGraphicsGrid grid, ShortPoint2D position) { if (currentTab != null) { if (grid.getPlayerIdAt(position.x, position.y) >= 0) { return grid.getPartitionData(position.x, position.y).getPartitionSettings().getDistributionSettings(currentTab.materialButton.getMaterial()); } } return null; }
private boolean hasTreeObject(int x, int y) { IMapObject o = map.getMap().getMapObjectsAt(x, y); while (o != null) { EMapObjectType type = o.getObjectType(); if (type == EMapObjectType.TREE_ADULT || type == EMapObjectType.TREE_DEAD) { return true; } o = o.getNextObject(); } return false; }
private IPartitionData getPartitonData() { if (currentGrid == null) { return null; } else { return currentGrid.getPartitionData(currentPos.x, currentPos.y); } }
public byte getVisibleStatus(int x, int y) { return map.getVisibleStatus(x, y); }
return; float height = context.getMap().getHeightAt(x, y); EDirection direction = ship.getDirection(); EDirection shipImageDirection = direction.rotateRight(3); // ship images have a different direction numbering
private void drawDebugColors() { GLDrawContext gl = this.context.getGl(); if(shapeHandle == null || !shapeHandle.isValid()) shapeHandle = gl.storeGeometry(shape, EGeometryFormatType.VertexOnly2D, false, "debugshape"); int drawX = context.getOffsetX(); int drawY = context.getOffsetY(); context.getScreenArea().stream().filterBounds(width, height).forEach((x, y) -> { try { int argb = map.getDebugColorAt(x, y, debugColorMode); if (argb != 0) { int height = context.getHeight(x, y); float dx = drawX+context.getConverter().getViewX(x, y, height); float dy = drawY+context.getConverter().getViewY(x, y, height); gl.draw2D(shapeHandle, null, EGeometryType.Quad, 0, 4, dx, dy, .5f, 1, 1, 1, Color.fromShort((short) argb), 1); } } catch (IllegalBufferException e) { // TODO: Create a crash report // This should never happen since we only use texture 0 (no texture) } }); }
ShortPoint2D underMouse = this.context.getPositionOnScreen((float) mousePosition.getX(), (float) mousePosition.getY()); if (0 <= underMouse.x && underMouse.x < width && 0 <= underMouse.y && underMouse.y < height) { IMapObject mapObject = map.getMapObjectsAt(underMouse.x, underMouse.y);
/** * Creates a new map context for a given map. * * @param map * The map. */ public MapDrawContext(IGraphicsGrid map) { this.map = map; float incline = DrawConstants.DISTANCE_X / 2.0f / DrawConstants.DISTANCE_Y; int mapHeight = map.getHeight() * DrawConstants.DISTANCE_Y; int mapWidth = map.getWidth() * DrawConstants.DISTANCE_X; this.screen = new ScreenPosition(mapWidth, mapHeight, incline); this.converter = MapCoordinateConverter.get(DrawConstants.DISTANCE_X, DrawConstants.DISTANCE_Y, map.getWidth(), map.getHeight() ); }
/** * @param screenX * The x coordinate in draw space * @param screenY * The y coordinate in draw space. * @return The map position under the point. */ private ShortPoint2D getPositionUnder(float screenX, float screenY) { // do a three step iteration by using the coordinate transformation and the map height int mapX = getConverter().getMapX(screenX, screenY); int mapY = getConverter().getMapY(screenX, screenY); if (mapX < 0 || map.getWidth() <= mapX || mapY < 0 || map.getHeight() <= mapY) { return new ShortPoint2D(mapX, mapY); } float height = map.getHeightAt(mapX, mapY); mapX = (int) (getConverter().getExactMapXwithHeight(screenX, screenY, height) + 0.5); mapY = (int) (getConverter().getExactMapYwithHeight(screenX, screenY, height) + 0.5); height = map.getHeightAt(mapX, mapY); mapX = (int) (getConverter().getExactMapXwithHeight(screenX, screenY, height) + 0.5); mapY = (int) (getConverter().getExactMapYwithHeight(screenX, screenY, height) + 0.5); return new ShortPoint2D(mapX, mapY); }
private Color getColorForArea(IGraphicsGrid map, int mapminX, int mapminY, int mapmaxX, int mapmaxY) { int centerx = (mapmaxX + mapminX) / 2; int centery = (mapmaxY + mapminY) / 2; return map.getLandscapeTypeAt(centerx, centery).color; }
public Minimap(MapDrawContext context, MinimapMode modeSettings) { this.context = context; IGraphicsGrid map = context.getMap(); stride = MiniMapLayoutProperties.getStride(map.getWidth()) / map.getWidth(); converter = new MapCoordinateConverter(map.getWidth(), map.getHeight(), 1, 1); miniMapShapeCalculator = new MiniMapShapeCalculator(stride, converter); lineLoader = new LineLoader(this, modeSettings); Thread miniMapThread = new Thread(lineLoader, "minimap loader"); miniMapThread.setDaemon(true); miniMapThread.start(); }
private void addColorPointToGeometry(MapDrawContext context, ByteBuffer buffer, int x, int y, int fogOffset) { float fColor; if (x <= 0 || x >= context.getMap().getWidth() - 2 || y <= 0 || y >= context.getMap().getHeight() - 2 || context.getVisibleStatus(x, y) <= 0) { fColor = 0; } else { int height1 = context.getHeight(x, y - 1); int height2 = context.getHeight(x, y); fColor = 0.85f + (height1 - height2) * .15f; if (fColor > 1.0f) { fColor = 1.0f; } else if (fColor < 0.4f) { fColor = 0.4f; } fColor *= (float) fogOfWarStatus[fogOffset] / CommonConstants.FOG_OF_WAR_VISIBLE; } if(useFloatColors) { buffer.putFloat(fColor); } else { byte color; fColor *= 255f; color = (byte) (int) fColor; buffer.put(color); buffer.put(color); buffer.put(color); buffer.put((byte) 255); } }