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$ } } }
/** * Build line of sight effects between coordinates c1 and c2 at height h1 * and h2 respectivly. * * @param c1 the source coordiantes. * @param c2 the target coordinates. * @param h1 the height in the source tile that is being shot from. * @param h2 the height of the target tile to shoot for. * @return an attackInfo object that describes the apliable modifiers. */ private LosEffects.AttackInfo buildAttackInfo(Coords c1, Coords c2, int h1, int h2) { LosEffects.AttackInfo ai = new LosEffects.AttackInfo(); ai.attackPos = c1; ai.targetPos = c2; ai.attackHeight = h1; ai.targetHeight = h2; ai.attackAbsHeight = server.getGame().getBoard().getHex(c1).floor() + h1; ai.targetAbsHeight = server.getGame().getBoard().getHex(c2).floor() + h2; return ai; }
/** * 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()); } }
/** * Ignores determining if the attack is on land or under water. * * @param c1 * @param c2 * @param h1 * @param h2 * @return */ private LosEffects.AttackInfo buildAttackInfo(Coords c1, Coords c2, int h1, int h2, boolean attackerIsMech, boolean targetIsMech) { LosEffects.AttackInfo ai = new LosEffects.AttackInfo(); ai.attackPos = c1; ai.targetPos = c2; ai.attackHeight = h1; ai.targetHeight = h2; ai.attackerIsMech = attackerIsMech; ai.targetIsMech = targetIsMech; ai.attackAbsHeight = client.getGame().getBoard().getHex(c1).floor() + h1; ai.targetAbsHeight = client.getGame().getBoard().getHex(c2).floor() + h2; return ai; }
public int elevationOccupied(IHex hex, int elevation) { if (hex == null) { return 0; } if ((movementMode == EntityMovementMode.VTOL) || (movementMode == EntityMovementMode.WIGE)) { return hex.surface() + elevation; } else if (((movementMode == EntityMovementMode.HOVER) || (movementMode == EntityMovementMode.NAVAL) || (movementMode == EntityMovementMode.HYDROFOIL) || hex.containsTerrain(Terrains.ICE)) && hex.containsTerrain(Terrains.WATER)) { return hex.surface(); } else { return hex.floor(); } }
case Terrains.ICE: case Terrains.FIELDS: level = Math.abs(x.floor());
getClient().getBoard().getHex(start).floor(), getClient().getBoard().getHex(end).floor())).losModifiers( getClient().getGame()); if (thd.getValue() != TargetRoll.IMPOSSIBLE) { getClient().getBoard().getHex(end).floor(), getClient().getBoard().getHex(start).floor())).losModifiers( getClient().getGame()); if (thd.getValue() != TargetRoll.IMPOSSIBLE) {
ce().setElevation(0); } else { ce().setElevation(deployhex.floor() - deployhex.surface());
/** * 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; }
.containsTerrain(Terrains.JUNGLE))) { return ((assumedElevation <= 50) && (assumedAlt >= hex.floor())); } else if (hex.containsTerrain(Terrains.BRIDGE_ELEV)) { && assumedElevation > hex.floor() && (assumedElevation > hex.terrainLevel(Terrains.BRIDGE_ELEV) || assumedElevation + height() < hex.terrainLevel(Terrains.BRIDGE_ELEV) - 1); if (this instanceof Infantry && ((Infantry)this).hasSpecialization(Infantry.SCUBA) && getMovementMode() == EntityMovementMode.INF_UMU) { return assumedAlt >= Math.max(hex.floor(), -2) && (assumedAlt <= hex.surface()); return ((assumedAlt >= hex.floor()) && (assumedAlt <= hex.surface())); } else if ((getMovementMode() == EntityMovementMode.HYDROFOIL) || (getMovementMode() == EntityMovementMode.NAVAL)) { } else if (getMovementMode() == EntityMovementMode.WIGE) { return (assumedAlt >= hex.floor()); } else { if (assumedAlt == hex.floor()) { return true;
int hexEl = ai.underWaterCombat ? hex.floor() : hex.surface();
&& (getHeight() >= hex.terrainLevel(Terrains.BRIDGE_ELEV) - hex.floor())) { return true;
int hexEl = ai.underWaterCombat ? hex.floor() : hex.surface();