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 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; } }
private IPartitionData getPartitonData() { if (currentGrid == null) { return null; } else { return currentGrid.getPartitionData(currentPos.x, currentPos.y); } }
if(map instanceof IDirectGridProvider) { IDirectGridProvider dgp = (IDirectGridProvider) map; objectsGrid = dgp.getObjectArray(); movableGrid = dgp.getMovableArray(); borderGrid = dgp.getBorderArray(); isVisibleGridAvailable = true; } else { isVisibleGridAvailable = false; width = map.getWidth(); height = map.getHeight(); this.gameTimeProvider = game.getGameTimeProvider(); this.textDrawPosition = textDrawPosition; this.connector.addListener(this); map.setBackgroundListener(background);
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);
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; }
public final void setHeightAt(short x, short y, byte height) { this.heightGrid[x + y * width] = height; backgroundListener.backgroundShapeChangedAt(x, y); }
/** * 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(); }
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; }
public byte getVisibleStatus(int x, int y) { return map.getVisibleStatus(x, y); }
public void flattenAndChangeHeightTowards(int x, int y, byte targetHeight) { final int index = x + y * width; this.heightGrid[index] += Math.signum(targetHeight - this.heightGrid[index]); this.landscapeGrid[index] = ELandscapeType.FLATTENED.ordinal; this.temporaryFlatened[index] = Byte.MAX_VALUE; // cancel the flattening backgroundListener.backgroundShapeChangedAt(x, y); }
/** * @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); }
/** * 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() ); }
/** * 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); }
public final void setLandscapeTypeAt(int x, int y, ELandscapeType landscapeType) { if (landscapeType == ELandscapeType.FLATTENED && this.landscapeGrid[x + y * width] != ELandscapeType.FLATTENED.ordinal) { flattenedResetter.addPosition(x, y); } this.landscapeGrid[x + y * width] = landscapeType.ordinal; backgroundListener.backgroundShapeChangedAt(x, y); }
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(); }
public void setHeight(int x, int y, int height) { byte safeHeight; if (height >= Byte.MAX_VALUE) { safeHeight = Byte.MAX_VALUE; } else if (height <= 0) { safeHeight = 0; } else { safeHeight = (byte) height; } undoDelta.addHeightChange(x, y, heights[x][y]); heights[x][y] = safeHeight; if (backgroundListener != null) { backgroundListener.backgroundShapeChangedAt((short) x, (short) y); } }
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); } }
private boolean setLandscape(int x, int y, ELandscapeType type) { if (objects[x][y] != null) { if (!landscapeAllowsObjects(type)) { return false; } if (objects[x][y] instanceof LandscapeConstraint) { LandscapeConstraint constraint = (LandscapeConstraint) objects[x][y]; if (!constraint.getAllowedLandscapes().contains(type)) { return false; } } } undoDelta.addLandscapeChange(x, y, landscapes[x][y]); landscapes[x][y] = type; if (backgroundListener != null) { backgroundListener.backgroundShapeChangedAt((short) x, (short) y); } return true; }
inverse.addHeightChange(c.x, c.y, heights[c.x][c.y]); heights[c.x][c.y] = c.height; backgroundListener.backgroundShapeChangedAt(c.x, c.y); c = c.next; inverse.addLandscapeChange(cl.x, cl.y, landscapes[cl.x][cl.y]); landscapes[cl.x][cl.y] = cl.landscape; backgroundListener.backgroundShapeChangedAt(cl.x, cl.y); cl = cl.next;