private void paintHeight(Graphics g, IHex h, int x, int y) { if (heightDisplayMode == SHOW_NO_HEIGHT) { return; } if (zoom > 2) { int baseX = (x * (hexSide[zoom] + hexSideBySin30[zoom])) + leftMargin; int baseY = (((2 * y) + 1 + (x % 2)) * hexSideByCos30[zoom]) + topMargin; g.setColor(Color.white); int height = 0; if ((h.getTerrain(Terrains.BUILDING) != null) && (heightDisplayMode == SHOW_BUILDING_HEIGHT)) { height = h.ceiling(); } else if (heightDisplayMode == SHOW_GROUND_HEIGHT) { height = h.floor(); } else if (heightDisplayMode == SHOW_TOTAL_HEIGHT) { height = ((h.getTerrain(Terrains.BUILDING) != null) || (h .getTerrain(Terrains.FUEL_TANK) != null)) ? h.ceiling() : h.floor(); } if (height != 0) { g.drawString(height + "", baseX + 5, baseY + 5); //$NON-NLS-1$ } } }
/** * Spreads the fire, and reports the spread, to the specified hex, if * possible, if the hex isn't already on fire, and the fire roll is made. */ public void spreadFire(Coords coords, TargetRoll roll, int height) { IHex hex = game.getBoard().getHex(coords); if (hex == null) { // Don't attempt to spread fire off the board. return; } if(Math.abs(hex.ceiling() - height) > 4) { return; } if (!(hex.containsTerrain(Terrains.FIRE)) && server.checkIgnition(coords, roll)) { Report r = new Report(5150, Report.PUBLIC); r.add(coords.getBoardNum()); vPhaseReport.addElement(r); } }
case Terrains.FUEL_TANK: case Terrains.BUILDING: level = Math.abs(x.ceiling());
/** * Determine if the given set of coordinates has a gun emplacement on the roof of a building. * @param c The coordinates to check */ public boolean hasRooftopGunEmplacement(Coords c) { Building building = getBoard().getBuildingAt(c); if(building == null) { return false; } IHex hex = getBoard().getHex(c); for (Entity entity : getEntitiesVector(c, true)) { if (entity.hasETypeFlag(Entity.ETYPE_GUN_EMPLACEMENT) && entity.getElevation() == hex.ceiling()) { return true; } } return false; }
/** * is the unit flying Nape of the Earth? (i.e. one elevation above ground) */ public boolean isNOE() { if (!isAirborne()) { return false; } if (game.getBoard().inAtmosphere()) { return (1 == (getAltitude() - game.getBoard().getHex(getPosition()) .ceiling(true))); } if (game.getBoard().onGround()) { return 1 == getAltitude(); } return false; }
/** * Helper function that calculates the effective elevation for a unit standing there. * @param hex The hex to check * @param entity The entity to check * @return The effective elevation */ private int calculateUnitElevationInHex(IHex hex, Entity entity) { // we calculate the height of a hex as "on the ground" by default // Special exceptions: // We are a mech, which can hopping on top of some buildings // We are naval unit going under a bridge, in which case the height is the water level (naval units go on the surface, mostly) // We are non-naval going into water but not onto a bridge, in which case the height is the floor (mechs sink to the bottom) int hexElevation = hex.getLevel(); if(entity.hasETypeFlag(Entity.ETYPE_MECH) && hex.containsTerrain(Terrains.BLDG_CF)) { hexElevation = hex.ceiling(); } else if(entity.isNaval() && hex.containsTerrain(Terrains.BRIDGE)) { hexElevation = hex.getLevel(); } else if(!entity.isSurfaceNaval() && hex.containsTerrain(Terrains.WATER) && !hex.containsTerrain(Terrains.BRIDGE)) { hexElevation = hex.floor(); } return hexElevation; }
elevation = Math.max(0, elevation - (hex.ceiling() - hex.surface() + 1));
|| hex.containsTerrain(Terrains.WATER) || hex.containsTerrain(Terrains.JUNGLE)) { return ((assumedElevation <= 50) && (assumedAlt > hex.ceiling())); return ((assumedElevation <= 50) && (assumedAlt >= hex.ceiling())); } else if ((getMovementMode() == EntityMovementMode.SUBMARINE) || ((getMovementMode() == EntityMovementMode.INF_UMU) && hex || (this instanceof Infantry)) { if ((assumedAlt >= (hex.surface() - hex.depth(true))) && (assumedAlt <= hex.ceiling())) { return true;
int ceil = board.getHex(pos).ceiling(board.inAtmosphere());
return false; } else if (elevation <= (destHex.ceiling() - destHex.surface())) {
|| hex.containsTerrain(Terrains.BLDG_ELEV)) && hex.ceiling() > currElevation; } else {
return; } else if (isAero && board.inAtmosphere() && (ce().getElevation() <= board.getHex(moveto).ceiling(true))) {
return (hex.containsTerrain(Terrains.WOODS) || hex.containsTerrain(Terrains.JUNGLE)) && hex.ceiling() > currElevation; default: return false;
&& game.getBoard().inAtmosphere() && !a.isOutControl()) { IHex desth = game.getBoard().getHex(getPosition()); if (altitude <= desth.ceiling(true)) { return; // can't fly into a cliff face or woods (unless out