Java Universal Role Playing Engine Version 0.3.9

jurpe.dungeon.rpgmap
Class Cell

java.lang.Object
  extended by jurpe.dungeon.rpgmap.Cell
All Implemented Interfaces:
java.io.Serializable

public final class Cell
extends java.lang.Object
implements java.io.Serializable

Cell is the logical abstraction of a dungeon cell. A cell contains six passages. A cell with six passages closed is a wall. Can contain doors and other furnishing.

See Also:
Serialized Form

Constructor Summary
Cell()
          Constructor.
Cell(short xx, short yy)
          Constructor
Cell(short xx, short yy, LocationType location)
          Constructor
 
Method Summary
 RpgMapPoint getCoordinates()
          Get cell coordinates
 int getDistanceFrom(RpgMapPoint point)
          Get the distance (in number of cells) from the given RpgMapPoint.
 Direction[] getDoorables()
          Return all the directions in which this cell may have a door.
 Direction[] getDoors()
          Get all directions with doors
 Direction[] getDoors(boolean open)
          Get all directions with doors that are opened or closed
 Location getLocation()
           
 short getNumberOfCorridors()
          Get the number of open corridors leading out of this cell.
 CellPassages getPassages()
          The passages from this cell
 boolean isCorridor(Direction dir)
          Return true if the passage between this cell and the cell in d direction is a corridor, that is, it's opened.
 boolean isDoor(Direction dir)
          Return true if there is a door in the direction dir
 boolean isLit()
          Return true if this cell is lit (by a torch...)
 boolean isSpecial()
          Return true if this cell is not a wall or a corridor.
 boolean isVisited()
          If this cell has been visited
 boolean isWall()
          A cell without exits is considered a wall
 void setCoordinates(short x, short y)
          Set cell coordinates
 void setCorridor(Direction dir, boolean opened)
          Set if the passage between this cell and the cell in dir direction is opened
 void setDoor(Direction dir)
          Set a door.
 void setLit(boolean isEnlight)
          Set this cell lit or not
 void setLocation(LocationType location)
          Set location type
 void setLocation(LocationType location, java.lang.String message)
          Set location type and message.
 void setVisited(boolean isVisited)
          If this cell has been visited
 void setWall()
          This cell becomes a wall.
 void setWall(boolean isWall)
          Determine if this cell is a wall or not
 java.lang.String toString()
          String with cell coordinates
 boolean wasLit()
          Return true if this cell has been lit (discovered) by the gamer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Cell

public Cell()
Constructor. Use setCoordinates after this call to set cell coordinates.


Cell

public Cell(short xx,
            short yy)
Constructor

Parameters:
xx - X coordinate of cell
yy - Y coordinate of cell

Cell

public Cell(short xx,
            short yy,
            LocationType location)
Constructor

Parameters:
xx - X coordinate of cell
yy - Y coordinate of cell
location - type of this cell (ie: inn, trainer, normal...)
Method Detail

isVisited

public boolean isVisited()
If this cell has been visited


setVisited

public void setVisited(boolean isVisited)
If this cell has been visited

Parameters:
isVisited -

setCoordinates

public void setCoordinates(short x,
                           short y)
Set cell coordinates


getPassages

public CellPassages getPassages()
The passages from this cell

Returns:
The passages from this cell

getLocation

public Location getLocation()
Returns:
Location

setLocation

public void setLocation(LocationType location)
Set location type

Parameters:
location - LocationType

setLocation

public void setLocation(LocationType location,
                        java.lang.String message)
Set location type and message.

Parameters:
message - Message shown when selecting location
location - LocationType

isSpecial

public boolean isSpecial()
Return true if this cell is not a wall or a corridor.

Returns:
boolean

isLit

public boolean isLit()
Return true if this cell is lit (by a torch...)

Returns:
true if this cell is lit

wasLit

public boolean wasLit()
Return true if this cell has been lit (discovered) by the gamer

Returns:

setLit

public void setLit(boolean isEnlight)
Set this cell lit or not

Parameters:
isEnlight -

getCoordinates

public RpgMapPoint getCoordinates()
Get cell coordinates

Returns:
cell coordinates

getDistanceFrom

public int getDistanceFrom(RpgMapPoint point)
Get the distance (in number of cells) from the given RpgMapPoint.

Parameters:
point -
Returns:

isWall

public boolean isWall()
A cell without exits is considered a wall

Returns:
true if this cell is a wall

setWall

public void setWall()
This cell becomes a wall.


setWall

public void setWall(boolean isWall)
Determine if this cell is a wall or not

Parameters:
isWall - true if this cell is a wall

getDoors

public Direction[] getDoors(boolean open)
Get all directions with doors that are opened or closed

Parameters:
open - If true, returns opened doors. Else, closed doors
Returns:
All opened or closed doors in a cell
Throws:
JurpeException

getDoors

public Direction[] getDoors()
Get all directions with doors

Returns:
Direction[]
Throws:
JurpeException

setDoor

public void setDoor(Direction dir)
Set a door. A door exist in the passages of this cell, and in the ones of the connected cell.

Parameters:
dir - Direction

getDoorables

public Direction[] getDoorables()
Return all the directions in which this cell may have a door. A cell is doorable if it has at least one corridor between two non-corridors.

Returns:
Direction

isCorridor

public boolean isCorridor(Direction dir)
Return true if the passage between this cell and the cell in d direction is a corridor, that is, it's opened.

Parameters:
dir - Direction adiacent cell
Returns:
true if the passage between this cell and the cell in d direction is opened

isDoor

public boolean isDoor(Direction dir)
Return true if there is a door in the direction dir

Parameters:
dir - Direction in which looking for a door
Returns:
True if door is found in direction dir

setCorridor

public void setCorridor(Direction dir,
                        boolean opened)
Set if the passage between this cell and the cell in dir direction is opened

Parameters:
dir - Direction from the center
opened - true if the passage in this direction is opened

getNumberOfCorridors

public short getNumberOfCorridors()
Get the number of open corridors leading out of this cell.

Returns:
the number of open corridors leading out of this cell

toString

public java.lang.String toString()
String with cell coordinates

Overrides:
toString in class java.lang.Object
Returns:
String with cell coordinates

Java Universal Role Playing Engine Version 0.3.9

Copyright ? 2010 http://jurpe.sourceforge.net/ All Rights Reserved.