IHex newHex = board.getHexInDir(loc.x, loc.y, dir); if ((newHex != null) && (!alreadyUsed.contains(newHex)) && (!notYetUsed.contains(newHex))
/** * Generates a fill gradient which is rotated and aligned properly for * the drawing area for a hex shadow effect in a lower hex. */ private final GradientPaint getElevationShadowGP(Coords src, int direction) { final IHex srcHex = game.getBoard().getHex(src); final IHex destHex = game.getBoard().getHexInDir(src, direction); if (destHex == null) return null; int ldiff = destHex.getLevel()-srcHex.getLevel(); // the shadow strength depends on the level difference, // but only to a maximum difference of 3 levels ldiff = Math.min(ldiff*5,15); Color c1 = new Color(30,30,50,255); // dark end of shadow Color c2 = new Color(50,50,70,0); // light end of shadow Point2D p1 = new Point2D.Double(41.5,-25+ldiff); Point2D p2 = new Point2D.Double(41.5,8.0+ldiff); AffineTransform t = new AffineTransform(); t.scale(scale,scale); t.rotate(Math.toRadians(direction*60),41.5,35.5); t.transform(p1,p1); t.transform(p2,p2); return(new GradientPaint(p1,c1,p2,c2)); }
/** * Extends a river hex to left and right sides. * * @param hexloc The location of the river hex, from which it should get * started. * @param width The width to wich the river should extend in the direction. * So the actual width of the river is 2*width+1. * @param direction Direction too which the riverhexes should be extended. * @return Hashset with the hexes from the side. */ private static HashSet<IHex> extendRiverToSide(IBoard board, Point hexloc, int width, int direction, HashMap<IHex, Point> reverseHex) { Point current = new Point(hexloc); HashSet<IHex> result = new HashSet<IHex>(); IHex hex; hex = board.getHexInDir(current.x, current.y, direction); while ((hex != null) && (width-- > 0)) { hex.removeAllTerrains(); hex.addTerrain(Terrains.getTerrainFactory().createTerrain( Terrains.WATER, 1)); result.add(hex); current = reverseHex.get(hex); hex = board.getHexInDir(current.x, current.y, direction); } return result; }
/** * Generates a Shape drawing area for the hex shadow effect in a lower hex * when a higher hex is found in direction. */ private final Shape getElevationShadowArea(Coords src, int direction) { final IHex srcHex = game.getBoard().getHex(src); final IHex destHex = game.getBoard().getHexInDir(src, direction); // When at the board edge, create a shadow in hexes of level < 0 if (destHex == null) { if (srcHex.getLevel() >= 0) return null; } else { // no shadow area when the current hex is not lower than the next hex in direction if (srcHex.getLevel() >= destHex.getLevel()) return null; } return(AffineTransform.getScaleInstance(scale, scale).createTransformedShape( HexDrawUtilities.getHexBorderArea(direction, HexDrawUtilities.CUT_BORDER, 36))); }
final IHex dest = game.getBoard().getHexInDir(c, dir); final IHex src = game.getBoard().getHex(c); IHex southHex = game.getBoard().getHexInDir(c, 3); if ((dir != 3) && (southHex != null) && (elev > southHex.getLevel())) {
switch (Compute.randomInt(4)) { case 0: field = board.getHexInDir(p.x, p.y, (direction + 5) % 6); break; case 1: field = board.getHexInDir(p.x, p.y, (direction + 1) % 6); break; default: field = board.getHexInDir(p.x, p.y, direction); break; field = board.getHexInDir(thisHex.x, thisHex.y, i); if ((field != null) && (field.getLevel() < minElevation)) { minElevation = field.getLevel();
int largestLevelDiff = 0; for (int dir: allDirections) { IHex adjHex = game.getBoard().getHexInDir(c, dir); if (adjHex == null) { continue;
/** * Returns true if an elevation line should be drawn between the starting * hex and the hex in the direction specified. Results should be transitive, * that is, if a line is drawn in one direction, it should be drawn in the * opposite direction as well. */ private final boolean drawElevationLine(Coords src, int direction) { final IHex srcHex = game.getBoard().getHex(src); final IHex destHex = game.getBoard().getHexInDir(src, direction); if ((destHex == null) && (srcHex.getLevel() != 0)) { return true; } else if (destHex == null) { return false; } else if (srcHex.getLevel() != destHex.getLevel()) { return true; } else { return (srcHex.floor() != destHex.floor()); } }
IHex destinationHex = game.getBoard().getHexInDir(startingPath.getFinalCoords(), FireControl.correctFacing(startingPath.getFinalFacing() + direction));