|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--Grid
Class for displaying the map and handling the Player Movements. Fires Events for battles and redirects
Player
,
People
,
MapObject
,
Redirect
,
RedirectEvent
,
Game
,
BattleEvent
,
Serialized FormField Summary | |
static int |
DEFAULTNUM
The default number of Rows/COlumns |
static int |
DOWN
Down direction |
static int |
LEFT
Left direction |
protected int |
numi
The number of rows |
protected int |
numj
The number of columns |
protected int |
pi
The position of the player, the row/i |
protected int |
pj
The position of the player, the column/j |
static int |
RIGHT
Right direction |
static int |
UP
Up direction |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
Grid()
Construct a new Grid of size Grid.DEFAULTNUM |
Method Summary | |
void |
addBattleListener(BattleListener bl)
Add a class to be notified of Battles |
void |
addRedirectListener(RedirectListener r)
Add a class to be notified of Battles |
void |
allowMonsterOnMap(int m)
Allow wild Monsters of type m on this. |
void |
beginBattleWithPlayer(MapObject opp)
Call to begin a battle with th Player, fires the events. |
boolean |
canMove(int i,
int j)
Determines if the Location specified can be moved into |
void |
destroy()
Destroy all threads tied to this by setting their Grid Objects to null. |
void |
fillGrid()
Fills the Grid in a standard manner, useful for debugging. |
void |
fillMonsters()
Removes the older wild Monsters, and add new ones randomly from th selection allowed. |
int |
getNumColumns()
Gets the number of columns |
int |
getNumRows()
Gets the number of rows. |
java.awt.Dimension |
getPerferredSize()
Returns the preferred size of this. |
Player |
getPlayer()
Gets the Player of this. |
void |
init()
Initialize the Grid, ie start the Peopl Moving, and fill this with wild Monsters |
MapObject |
isPeopleInDirection(int i,
int j,
int dir,
int distance)
Returns the MapObject in the direction specified within the distance specified from the i, j specified. |
boolean |
isValidLocation(int i,
int j)
Determines if the Location specified is a valid on this. |
Location |
locationOf(MapObject mp)
Gets the Location of the specified MapObject, uses equals(Object o). |
MapObject |
mapObjectAt(int i,
int j)
Gets the MapObject at i, j. |
void |
moveMapObjectTo(int i,
int j,
int ni,
int nj)
Moves the MapObject at i, j to ni, nj. |
void |
movePlayerTo(int direction)
Moves the Player in the direction specified |
void |
paint(java.awt.Graphics g)
Draws the components of this |
void |
processEvent(java.awt.AWTEvent e)
Handle the Events. |
void |
removeAllObjects()
Remove All Objects from the Grid. |
void |
removeBattleListener(BattleListener bl)
Removes a class that was being notified. |
MapObject |
removeObject(int i,
int j)
Removes and returns the MapObject at the specified Location |
void |
removeRedirectListener(RedirectListener r)
Removes a class that was being notified. |
void |
repaint(int i,
int j)
Repaint the Location specified. |
void |
setDefault(MapObject m)
Sets the default backdrop to display. |
void |
setMonsterLevel(int l)
Sets the wild Monsters level for this |
void |
setObjectAt(MapObject mp,
int i,
int j)
Sets the object at the Location specified |
void |
setPlayer(Player p)
Sets the Player of this. |
void |
update(java.awt.Graphics g)
Overriden to rmove the flickering effect |
Methods inherited from class java.awt.Panel |
addNotify, getAccessibleContext |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int DEFAULTNUM
public static final int LEFT
public static final int RIGHT
public static final int UP
public static final int DOWN
protected int numi
protected int numj
protected int pi
protected int pj
Constructor Detail |
public Grid()
Method Detail |
public int getNumRows()
public int getNumColumns()
public boolean isValidLocation(int i, int j)
i
- the rowj
- the column
public boolean canMove(int i, int j)
i
- the rowj
- the column
MapObject
,
Grass
,
Floor
public void setDefault(MapObject m)
m
- the MapObject to have as the backdroppublic java.awt.Dimension getPerferredSize()
Game
public void setPlayer(Player p)
p
- the new Player of thispublic void setObjectAt(MapObject mp, int i, int j) throws InvalidLocationException, NonEmptyException
mp
- the MapObject to set at i, ji
- the rowj
- the column
InvalidLocationException
- iff !isValidException(i, j)
NonEmptyException
- iff !canMove(i, j)public MapObject removeObject(int i, int j) throws InvalidLocationException
i
- the rowj
- the column
InvalidLocationException
- iff !isValidException(i, j)public void removeAllObjects()
public MapObject mapObjectAt(int i, int j) throws EmptyLocationException, InvalidLocationException
i
- the rowj
- the columne
InvalidLocationException
- iff !isValidException(i, j)
EmptyLocationException
- if the Location only contains the default MapObjectpublic Location locationOf(MapObject mp) throws InvalidLocationException
mp
- the MapObject to search for.
InvalidLocationException
public MapObject isPeopleInDirection(int i, int j, int dir, int distance) throws InvalidLocationException
i
- the rowj
- the columndir
- the direction as specified abovedistance
- the distance to look
InvalidLocationException
- iff !isValidException(i, j)public Player getPlayer()
public void movePlayerTo(int direction) throws NonEmptyException, InvalidLocationException
direction
- the direction to move the player, as specified above
NonEmptyException
InvalidLocationException
public void moveMapObjectTo(int i, int j, int ni, int nj) throws NonEmptyException, InvalidLocationException, EmptyLocationException
i
- the row originally atj
- the column origanally atni
- the new rownj
- the new column
InvalidLocationException
- iff !isValidException(i, j)
NonEmptyException
- iff !canMove(i, j)
EmptyLocationException
- Will Not Be Thrown.public void processEvent(java.awt.AWTEvent e)
processEvent
in class java.awt.Container
e
- the AWTEvent to processpublic void allowMonsterOnMap(int m)
m
- the Monster.public void setMonsterLevel(int l)
l
- the level of the wild Monsterspublic void fillGrid()
public void init()
public void fillMonsters()
public void destroy()
PersonAI
,
Trainer
public void paint(java.awt.Graphics g)
paint
in class java.awt.Container
g
- the Graphicspublic void update(java.awt.Graphics g)
update
in class java.awt.Container
g
- the Graphicspublic void repaint(int i, int j)
i
- the rowj
- the columnpublic void addBattleListener(BattleListener bl)
public void removeBattleListener(BattleListener bl)
public void addRedirectListener(RedirectListener r)
public void removeRedirectListener(RedirectListener r)
public void beginBattleWithPlayer(MapObject opp)
opp
- the Opponent of the Player.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |