|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--netwar.game.Hex
This class represents a single hexagon-shaped region of game-space. These regions are used to simplify path-finding algorithms, graphical draw-order, and terrain logic and display. A Hex may contain up to one GameObject at a time.
| Field Summary | |
static double |
sqrt3
The square root of three, which is particularly relavent to hexagon geometry. |
| Constructor Summary | |
protected |
Hex(HexType h)
This constructor initializes the Hex according to a HexType's initializing data. |
| Method Summary | |
static void |
draw(GameViewer v)
Draws all hexes onto GameViewer v. |
static void |
drawGameObject(GameViewer v)
Draws all the GameObjects in the game onto GameViewer v. |
boolean |
enter(GameObject u)
Attempts to put the GameObject into this Hex. |
static Hex |
getHex(int x,
int y)
Retrieves a Hex from the board. |
static Point2D |
getHexDimension()
Returns the size of a rectangle just big enough to contain one Hex. |
static Point3D |
getMapPoint(int x,
int y)
Gets the ground-center of the Hex at hex coordinate (x,y). |
java.awt.Color |
getMinimapColor()
Returns the Color to display on the minimap. |
GameObject |
getOccupant()
Returns the GameObject which is in the Hex. |
static Hex |
getXY(Point3D vr)
Gets the Hex containing a game-space point, and alters the parameter to contain the hex coordinates, by storing the hex x in vr.x and the hex y in vr.y |
boolean |
isEmpty()
Checks if the Hex is unoccupied. |
void |
leave(GameObject u)
Removes the GameObject from the Hex, if it is the GameObject which was in the Hex. |
static void |
makeBoard(int rad)
Initializes the board, which is a static array of Hex objects, designed to produce a hexagon of hexagons. |
static int |
radialX(int radial,
int offset,
boolean fromEdge)
Used for determining initial base locations. |
static int |
radialY(int radial,
int offset,
boolean fromEdge)
Used for determining initial base locations. |
boolean |
reserve()
Attempts to reserve this Hex for the caller. |
void |
unreserve()
Unreserves this Hex. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final double sqrt3
| Constructor Detail |
protected Hex(HexType h)
h - The HexType containing the data for this type of Hex.| Method Detail |
public static int radialX(int radial,
int offset,
boolean fromEdge)
radial - a number from 0 to 11 indicating the direction from the center.offset - the distance along that radian.fromEdge - if true, count the distance (offset) from the edge of the map, instead of the center.
public static int radialY(int radial,
int offset,
boolean fromEdge)
radial - a number from 0 to 11 indicating the direction from the center.offset - the distance along that radian.fromEdge - if true, count the distance (offset) from the edge of the map, instead of the center.public static void makeBoard(int rad)
rad - The radius of the board in Hexes.
public static Hex getHex(int x,
int y)
x - The x part of the Hex coordinate of the desired hex.y - The y part of the Hex coordinate of the desired hex.public static void draw(GameViewer v)
v - A GameViewer seeking to display the entire map (or at least the visible portion).public static void drawGameObject(GameViewer v)
v - The GameViewer seeking to display all of the GameObjects.
public static Point3D getMapPoint(int x,
int y)
x - The x part of the hex coordinate.y - The y part of the hex coordinate.public static Hex getXY(Point3D vr)
vr - The game-space point to locate, and the storage space for the x and y.public boolean reserve()
public void unreserve()
public boolean enter(GameObject u)
u - The GameObject which is attempting to occupy the Hex.public void leave(GameObject u)
u - The GameObject which is leaving the Hex.public boolean isEmpty()
public GameObject getOccupant()
public java.awt.Color getMinimapColor()
public static Point2D getHexDimension()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||