|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjecthexIT.Board
hexIT.HexagonalBoard
A hexagonal board is a board which is itself arranged into one big hexagon composed of smaller ones. A hexagonal board of size 3 is depicted below.
Coord System & Example: y-coord 0 1 2 / / / 3 0- . . . / 4 1- . . . . / x-coord 2- . . . . . 3- . . . x <-- that 'x' is at position (3,4) 4- . . .
Field Summary | |
static int |
DIR_E
|
static int |
DIR_NE
|
static int |
DIR_NW
|
static int |
DIR_SE
|
static int |
DIR_SW
|
static int |
DIR_W
|
Constructor Summary | |
HexagonalBoard()
Create an empty hexagonal board with no size. |
|
HexagonalBoard(int new_size)
Create a hexagonal board of the specified size. |
Method Summary | |
int |
distance(Hexagon h1,
Hexagon h2)
Returns the minimum # of hexes need to travel from one hexagon to the other. |
java.util.List |
getExterior()
Returns the list of hexagons on the outer edges. |
java.util.List |
getFOV(int hexx1,
int hexy1,
int maxradius)
Get the list of hexagons in the Field-of-View from the source hexagon at hex location (hexx1, hexy1). |
Hexagon |
getHexagon(int x,
int y)
Return the hexagon at hex location (x,y) or null if invalid coordinates, or null if the location is not valid. |
Hexagon |
getHexagonByPixel(int pixx,
int pixy)
Gets the hexagon which contains this pixel. |
Hexagon[] |
getHexagons()
Returns an array of all valid hexagons on this hexagonal board, in no particular order. |
java.util.List |
getLOS(int hexx1,
int hexy1,
int hexx2,
int hexy2)
Returns the line-of-sight from hexagon at hex location (hexx1,hexy1). |
java.util.List |
getLOSPixel(int hexx1,
int hexy1,
int iBx,
int iBy)
Returns the line-of-sight from hexagon at hex location (hexx1,hexy1). |
Hexagon[] |
getNonOccupiedHexagons()
Returns an array of all valid hexagon on this hexagonal board that are not occupied by pieces, in no particular order. |
Hexagon[] |
getOccupiedHexagons()
Returns an array of all valid hexagon on this hexagonal board that are occupied by pieces, in no particular order. |
java.util.List |
getShortestPath(int hexx1,
int hexy1,
int hexx2,
int hexy2)
Returns the list of hexagons that forms the shortest path between the source hexagon at (hexx1,hexy1) and destination hexagon at (hexx2,hexy2). |
int |
getSideLength()
Returns the side length. |
java.util.List |
getSurrounding(int hexx,
int hexy,
int radius)
Get all the hexagons surround the given source hexagon at (hexx,hexy) within the specified radius. |
Hexagon[] |
getSurroundingArray(Hexagon h,
int radius)
Get all the hexagons surround the given source hexagon (h) within the specified radius. |
int |
isStraightPath(Hexagon h1,
Hexagon h2)
If there is a straight line of hexagons (ie: you can get there by going in one constant direction) between the source and destination, then the direction (from source to dest) is returned. |
int |
isStraightPath(int hexx1,
int hexy1,
int hexx2,
int hexy2)
If there is a straight line of hexagons (ie: you can get there by going in one constant direction) between the source and destination, then the direction (from source to dest) is returned. |
boolean |
isValidCoord(int x,
int y)
Returns true if the specified hexagonal coordinates are not valid. |
void |
moveObject(Hexagon h1,
Hexagon h2)
Move the object at hex location h1 to h2. |
void |
moveObject(int x,
int y,
int direction)
Move the object at hex location (x,y) in the specified direction. |
void |
moveObject(int x1,
int y1,
int x2,
int y2)
Move the object at hex location (x1,y1) to (x2,y2). |
Hexagon |
nextHexagon(Hexagon h,
int dir)
Returns the hexagon which is of distance 1 away in the specified direction from the specified Hexagon. |
int |
nextX(int x,
int dir)
Returns the next value of the hex x-coordinate given the current value x and moving in the specified direction. |
int |
nextY(int y,
int dir)
Returns the next value of the hex y-coordinate given the current value x and moving in the specified direction. |
void |
putObject(int x,
int y,
Drawable obj)
Put the specified object on hex location (x,y). |
void |
removeObject(int x,
int y)
Remove the object on hex location (x,y). |
java.util.Iterator |
tilesIterator()
Returns an iterator over all hexagons on the board. |
Methods inherited from class hexIT.Board |
createFrame, findObject, setFrameSize, show |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DIR_NW
public static final int DIR_NE
public static final int DIR_W
public static final int DIR_E
public static final int DIR_SW
public static final int DIR_SE
Constructor Detail |
public HexagonalBoard()
public HexagonalBoard(int new_size)
Method Detail |
public int distance(Hexagon h1, Hexagon h2)
distance
in class Board
public boolean isValidCoord(int x, int y)
public Hexagon getHexagon(int x, int y)
public int getSideLength()
public void moveObject(Hexagon h1, Hexagon h2)
public void moveObject(int x1, int y1, int x2, int y2)
public void moveObject(int x, int y, int direction)
public void putObject(int x, int y, Drawable obj)
public void removeObject(int x, int y)
public java.util.Iterator tilesIterator()
tilesIterator
in class Board
public Hexagon getHexagonByPixel(int pixx, int pixy)
public Hexagon[] getHexagons()
public Hexagon[] getOccupiedHexagons()
public Hexagon[] getNonOccupiedHexagons()
public java.util.List getShortestPath(int hexx1, int hexy1, int hexx2, int hexy2)
getShortestPath
in class Board
public java.util.List getExterior()
getExterior
in class Board
public Hexagon nextHexagon(Hexagon h, int dir)
public int nextX(int x, int dir)
public int nextY(int y, int dir)
public int isStraightPath(Hexagon h1, Hexagon h2)
public int isStraightPath(int hexx1, int hexy1, int hexx2, int hexy2)
public java.util.List getLOSPixel(int hexx1, int hexy1, int iBx, int iBy)
public java.util.List getLOS(int hexx1, int hexy1, int hexx2, int hexy2)
getLOS
in class Board
public Hexagon[] getSurroundingArray(Hexagon h, int radius)
public java.util.List getSurrounding(int hexx, int hexy, int radius)
getSurrounding
in class Board
public java.util.List getFOV(int hexx1, int hexy1, int maxradius)
getFOV
in class Board
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |