/** * Returns an array of the Coords of hexes that are crossed by a straight * line from the center of src to the center of dest, including src & dest. * The returned coordinates are in line order, and if the line passes * directly between two hexes, it returns them both. Based on the degree of * the angle, the next hex is going to be one of three hexes. We check those * three hexes, sides first, add the first one that intersects and continue * from there. Based off of some of the formulas at Amit's game programming * site. (http://www-cs-students.stanford.edu/~amitp/gameprog.html) * * Note: this function can return Coordinates that are not on the board. * * @param src Starting point. * @param dest Ending Point. * @return The list of intervening coordinates. */ public static ArrayList<Coords> intervening(Coords src, Coords dest) { return intervening(src, dest, false); }
/** * @param aPos - attacking entity * @param tPos - targeted entity * @return a vector of all the entities that are adjacent to the targeted * entity and would fall along the angle of attack */ public static ArrayList<Entity> getAdjacentEntitiesAlongAttack(Coords aPos, Coords tPos, IGame game) { ArrayList<Entity> entities = new ArrayList<Entity>(); ArrayList<Coords> coords = Coords.intervening(aPos, tPos); // loop through all intervening coords for (Coords c : coords) { // must be adjacent to the target if ((c.distance(tPos) > 1) || c.equals(tPos)) { continue; } // now lets add all the entities here for (Entity en : game.getEntitiesVector(c)) { entities.add(en); } } return entities; }
/** * Get Entities that have have a iNarc Nemesis pod attached and are situated * between two Coords * * @param attacker The attacking <code>Entity</code>. * @param target The <code>Coords</code> of the original target. * @return a <code>Enumeration</code> of entities that have nemesis pods * attached and are located between attacker and target and are * friendly with the attacker. */ public Enumeration<Entity> getNemesisTargets(Entity attacker, Coords target) { final Coords attackerPos = attacker.getPosition(); final ArrayList<Coords> in = Coords.intervening(attackerPos, target); Vector<Entity> nemesisTargets = new Vector<Entity>(); for (Coords c : in) { for (Entity entity : getEntitiesVector(c)) { if (entity.isINarcedWith(INarcPod.NEMESIS) && !entity.isEnemyOf(attacker)) { nemesisTargets.addElement(entity); } } } return nemesisTargets.elements(); }
public static boolean hasFireBetween(Coords start, Coords end, IGame game) { ArrayList<Coords> in = Coords.intervening(start, end); for ( Coords hex : in ) { // ignore off-board hexes if (!game.getBoard().contains(hex)) { continue; } if ( game.getBoard().getHex(hex).containsTerrain(Terrains.FIRE) ) { return true; } } return false; }
ArrayList<Coords> coords = Coords.intervening(a, b);
ArrayList<Coords> coords = Coords.intervening(a, b);
ArrayList<Coords> coords = Coords.intervening(a, b);
/** * Updates the supplied Game's list of hexes illuminated. * * @param game The game to update * @return True if new hexes were added, else false. */ public boolean setHexesIlluminated(IGame game) { boolean hexesAdded = false; final Entity attacker = getEntity(game); final Coords apos = attacker.getPosition(); final Targetable target = getTarget(game); final Coords tpos = target.getPosition(); ArrayList<Coords> intervening = Coords.intervening(apos, tpos); for (Coords c : intervening) { if (game.getBoard().contains(c)){ hexesAdded |= game.addIlluminatedPosition(c); } } return hexesAdded; }
/** * Check for ferrous metal content in terrain on path from a to b return the * total content. */ public static int getMetalInPath(Entity ae, Coords a, Coords b) { // If we're in space, or anything is null... get out. if ((ae == null) || (a == null) || (b == null)) { return 0; } IBoard board = ae.getGame().getBoard(); if (board.inSpace()) { return 0; } if (!board.contains(a) || !board.contains(b)) { return 0; } // get intervening Coords. ArrayList<Coords> coords = Coords.intervening(a, b); // loop through all intervening coords, check each if they are ECM // affected int metalContent = 0; for (Coords c : coords) { IHex hex = board.getHex(c); if (hex != null && hex.containsTerrain(Terrains.METAL_CONTENT)) { metalContent += hex.terrainLevel(Terrains.METAL_CONTENT); } } return metalContent; }
public boolean willIlluminate(IGame game, Entity who) { if (!isPossible(game)) { return false; } final Entity attacker = getEntity(game); final Coords apos = attacker.getPosition(); final Targetable target = getTarget(game); final Coords tpos = target.getPosition(); ArrayList<Coords> in = Coords.intervening(apos, tpos); // nb includes // attacker & // target for (Coords c : in) { for (Entity en : game.getEntitiesVector(c)) { LosEffects los = LosEffects.calculateLos(game, getEntityId(), en); if (los.canSee() && en.equals(who)) { return true; } } } return false; } }
ArrayList<Coords> in = Coords.intervening(ai.attackPos, ai.targetPos); LosEffects los = new LosEffects(); boolean targetInBuilding = false;
ArrayList<Coords> in = Coords.intervening(apos, tpos); // nb includes
wtype = (WeaponType) weapon.getType(); ArrayList<Coords> coords = Coords.intervening(ae.getPosition(), entityTarget.getPosition()); int refrac = 0;
ArrayList<Coords> coords = Coords.intervening(a, b); ECMInfo worstECMEffects = null;
ArrayList<Coords> in = Coords.intervening(start, end); if ((degree % 60) == 30) { split = true; in = Coords.intervening(start, end, true);
final IHex srcHex = game.getBoard().getHex(src); final IHex destHex = game.getBoard().getHex(dest); final ArrayList<Coords> intervening = Coords.intervening(src, dest); final int direction = src.direction(dest);
getPosition(), 1, getElevation(), srcHex.floor(), curHex.floor()); ArrayList<Coords> in = Coords.intervening(ai.attackPos, ai.targetPos, true); leftBetter = LosEffects.dividedLeftBetter(in, game, ai,
LosEffects.AttackInfo ai = LosEffects.buildAttackInfo(src, getPosition(), 1, getElevation(), srcHex.floor(), curHex.floor()); ArrayList<Coords> in = Coords.intervening(ai.attackPos, ai.targetPos, true); leftBetter = LosEffects.dividedLeftBetter(in, game, ai,
ArrayList<Coords> in = Coords.intervening(lowPos, highPos, true); int IntElev = lowElev; Coords IntPos = lowPos;
getPosition(), 1, getElevation(), srcHex.floor(), curHex.floor()); ArrayList<Coords> in = Coords.intervening(ai.attackPos, ai.targetPos, true); leftBetter = LosEffects.dividedLeftBetter(in, game, ai,