|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.adom.jade.world.maps.Map
Defines a map. Maps can be either finite or infinite. Infinite maps wrap around the borders.
The map listener code is optimized for fast listener calls. Adding and removing listeners in turn is costly.
| Constructor Summary | |
|---|---|
Map(Location theLocation,
int theWidth,
int theHeight,
boolean finite,
Tile initialBlockingMapTile,
Tile initialMapTile)
Creates a new map with a given width and height. |
|
Map(Location theLocation,
int theWidth,
int theHeight,
boolean finite,
Tile initialBlockingMapTile,
Tile initialMapTile,
Tile openTile,
int openTileRange)
Creates a new map with a given width and height. |
|
| Method Summary | |
|---|---|
void |
addArea(Area area)
Adds an area to the map. |
void |
addMapListener(MapListener listener)
Adds a new map listener to this map. |
void |
attach(int x,
int y,
Complex complex)
Attaches a new complex in a given position to the location to which this map belongs. |
void |
buildConnections()
Builds all undefined connections into the game when this map is created. |
protected void |
fireMapUpdated(int x,
int y)
Notifies all listeners of an update to the map. |
AreaList |
getAreas(int x,
int y)
Returns the area at a specified position. |
Being |
getBeing(int x,
int y)
Returns a being at a given position. |
int |
getDirectionalXModifier(int povX,
int x)
Returns the x modifier for two positions to be able to trace routes from a point of view. |
int |
getDirectionalYModifier(int povY,
int y)
Returns the y modifier for two positions to be able to trace routes from a point of view. |
int |
getDistance(int x1,
int y1,
int x2,
int y2)
Determines the distance between two positions. |
int |
getDX(int x1,
int x2)
Returns the horizontal distance between two points and takes wrapping into account. |
int |
getDY(int y1,
int y2)
Returns the vertical distance between two points and takes wrapping into account. |
int |
getHeight()
Returns the height of the map. |
Location |
getLocation()
Returns the location to which this map belongs. |
MapView |
getMapView()
Returns the map view for this map. |
protected Tile |
getOpenBuilderTile()
Returns the tile used for spaces open for other buildings. |
int |
getRandomX()
Returns a random x coordinate within the boundaries of the map. |
int |
getRandomY()
Returns a random y coordinate within the boundaries of the map. |
int |
getSightRange(Being being)
Returns the sight range for a given being on this map. |
Tile |
getTile(int x,
int y)
Returns a tile at a specific position. |
int |
getVisibilityBlockadeLevel(int fromX,
int fromY,
int toX,
int toY)
Determines how much sight is blocked by the tiles between two positions. |
int |
getWidth()
Returns the width of the map. |
int |
getWrappedX(int x)
Returns the x coordinate in a normalized way. |
int |
getWrappedY(int y)
Returns the y coordinate in a normalized way. |
boolean |
isDark(int x,
int y)
Determines whether a given position is shrouded in unnatural darkness. |
boolean |
isEmpty(int x1,
int y1,
int x2,
int y2)
Checks whether a map area is open to take up a building. |
boolean |
isFinite()
Determines whether the map is finite or not. |
boolean |
isValidPosition(int x,
int y)
Determines whether a position is a valid map position or not. |
protected void |
placeAreas(AreaCreator areaCreator)
Places a number of areas on the map. |
void |
removeBeing(Being being)
Remove a being at a given position. |
void |
removeMapListener(MapListener listener)
Removes a given map listener from this list. |
void |
setBeing(Being being)
Sets a being at a given position. |
void |
setDark(int x,
int y,
boolean darkness)
Marks the darkness status of a given position. |
void |
setPointOfView(Being being)
Sets the point of view by using a being as the reference point. |
void |
setTile(int x,
int y,
Tile theTile)
Sets a specific tile at a given position. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Map(Location theLocation,
int theWidth,
int theHeight,
boolean finite,
Tile initialBlockingMapTile,
Tile initialMapTile)
theLocation - the location to which this map belongstheWidth - the width of the new maptheHeight - the height of the new mapisFinite - determines whether the map is finite or notinitialBlockingMapTile - the tile used for blocked spaces (usually the map
boundaries for finite maps)initialMapTile - the default map tile used for all map locations
public Map(Location theLocation,
int theWidth,
int theHeight,
boolean finite,
Tile initialBlockingMapTile,
Tile initialMapTile,
Tile openTile,
int openTileRange)
theLocation - the location to which this map belongstheWidth - the width of the new maptheHeight - the height of the new mapisFinite - determines whether the map is finite or notinitialBlockingMapTile - the tile used for blocked spaces (usually the map
boundaries for finite maps)initialMapTile - the default map tile used for all map locationsopenTile - the tile used to represent an open space for building purposesopenTileRange - the area that must be left open between two filled areas| Method Detail |
|---|
public void addMapListener(MapListener listener)
listener - the listener to addpublic void removeMapListener(MapListener listener)
listener - the listener to remove
java.lang.IllegalArgumentException - if the listener does
not exist in the listener list
ArrayIndexOutOfBoundsException, - if trying to
remove a listener that was added more than once
protected void fireMapUpdated(int x,
int y)
x - the x coordinate for the tiley - the y coordinate for the tile
public void setTile(int x,
int y,
Tile theTile)
x - the x coordinate for the tiley - the y coordinate for the tiletheTile - the tile to set
public Tile getTile(int x,
int y)
x - the x coordinate in questiony - the y coordinate in question
public final int getWrappedX(int x)
x - the x coordinate
public final int getWrappedY(int y)
y - the y coordinate
public boolean isValidPosition(int x,
int y)
x - the x coordinate of the positiony - the y coordinate of the position
public int getDistance(int x1,
int y1,
int x2,
int y2)
x1 - the x coordinate of the first positiony1 - the y coordinate of the first positionx2 - the x coordinate of the second positiony2 - the y coordinate of the second position
public int getDX(int x1,
int x2)
x1 - the first pointx2 - the second point
public int getDY(int y1,
int y2)
y1 - the first pointy2 - the second point
public boolean isFinite()
public MapView getMapView()
public int getWidth()
public int getHeight()
public int getSightRange(Being being)
being - the being
public boolean isDark(int x,
int y)
x - the x coordinate of the positiony - the y coordinate of the position
public void setDark(int x,
int y,
boolean darkness)
x - the x coordinate of the positiony - the y coordinate of the positiondarkness - a boolean value determining whether the given
position is dark or not
public int getVisibilityBlockadeLevel(int fromX,
int fromY,
int toX,
int toY)
fromX - the x coordinate of the start positionfromY - the y coordinate of the start positiontoX - the x coordinate of the target positiontoY - the y coordinate of the target position
public int getDirectionalXModifier(int povX,
int x)
povX - the x point of viewx - the x target point
public int getDirectionalYModifier(int povY,
int y)
povY - the y point of viewy - the y target point
public void setPointOfView(Being being)
being - the being to use as the reference being for the next
map viewpublic void setBeing(Being being)
being - the being itselfpublic void removeBeing(Being being)
being - the being itself
public Being getBeing(int x,
int y)
x - the x position to be examinedy - the y position to be examined
nullpublic Location getLocation()
public void attach(int x,
int y,
Complex complex)
x - the x position of the new complexy - the y position of the new complexcomplex - the new complexpublic void buildConnections()
public boolean isEmpty(int x1,
int y1,
int x2,
int y2)
x1 - the left x coordinate of the areay1 - the left y coordinate of the areax2 - the right x coordinate of the areay2 - the right y coordinate of the area
protected Tile getOpenBuilderTile()
public void addArea(Area area)
area - the area to add to the map
public AreaList getAreas(int x,
int y)
x - the x positiony - the y position
public int getRandomX()
public int getRandomY()
protected void placeAreas(AreaCreator areaCreator)
areaCreator - the creator used to define the areas
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||