be.saltwater.jaqel.creature
Class Creature

java.lang.Object
  extended bybe.saltwater.jaqel.creature.Creature
Direct Known Subclasses:
Hero, Monster

public abstract class Creature
extends java.lang.Object

Defines characters which can execute CreatureAction objects. A creature has serveral "points" which can be set and get. Points that are needed by identity (e.g. in the shop), are stored in CreatureSharedData. A creature also has locators. These are indicators that can move when the creature moves. You can attach and detach CreatureAttribute objects to these locators with attachAttribute() and detachAttribute(). If you attach an attribute to an non-existent locator, the attribute will not move. See the animation files for what locator names are valid.

Author:
Robin Wittevrongel, Bruno Windels
See Also:
CreatureSharedData, be.saltwater.jaqel.session.Identity

Field Summary
static int ORDER_ERROR
          the order couldn't be completed for some unknown reason
static int ORDER_NOPATH
          the order couldn't be completed because there is no path to the given point
static int ORDER_NOTENOUGHMAGIC
           
static int ORDER_NOTENOUGHPOINTS
          the order couldn't be completed because this hero does not have enough action or other points
static int ORDER_NOTYOURTURN
           
static int ORDER_NOWEAPON
           
static int ORDER_OK
          the order was processed correctly
static int ORDER_TILENOTFREE
          the order couldn't be completed because the tile is taken (e.g. in a move order)
static int ORDER_TILENOTTAKEN
          the order couldn't be completed because the tile is not taken (e.g. in an attack order)
 
Constructor Summary
Creature(CreatureTypeData type_data, CreatureSharedData points)
          Constructs a creature (abstract).
 
Method Summary
 void addActions()
          Called by Level when it's this creatures turn.
protected abstract  void addActionsInternal()
          Must be overridden by subclasses to add actions to the scheduler.
 void attachAttribute(CreatureAttribute attr, java.lang.String location)
          Attach an attribute, such as a weapon, to a certain locator in this creature.
 int attack(Creature c, int times)
           
 int attack(java.awt.Point where, int times)
          Add an action to the CreatureActionScheduler to attack another creature in the maze.
 javax.media.j3d.Morph createMorph(javax.media.j3d.GeometryArray[] keyframes)
          Get the Morph object that contains the graphical representation for this creature.
 void detachAttribute(CreatureAttribute attr)
          Detaches the given attribute from any locator in this creature.
 java.util.List findPath(java.awt.Point endPoint, boolean approach)
          An algorithm that looks for the shortest way to a certain tile in the Maze and returns an ArrayList of points, referring to the tiles upon which the Creature has to walk.
 void finishTurn()
           
 int getActionPoints()
           
 javax.media.j3d.BranchGroup getBranchGroup()
           
 CreatureAnimation getCreatureAnimation(java.lang.String key)
          Get the creature animation with the given name (walk, fight, ...) of this creature.
 CreatureSharedData getCreatureSharedData()
           
 CreatureTypeData getCreatureTypeData()
          Returns the type data of this creature.
 Weapon getCurrentWeapon()
           
 java.lang.String getCurrentWeaponName()
           
 int getDrinkCost()
           
 java.awt.Point getEndLocation()
          Get the location of the creature when all his actions that are currently queued in the action scheduler are finished.
 int getHealthPoints()
           
 Level getLevel()
           
 java.awt.Point getLocation()
          Get the creature's current location in the maze.
 javax.media.j3d.TransformGroup getLocatorGroup(java.lang.String key)
          Get the TransformGroup of the given locator, or return null if not in use.
 javax.media.j3d.Morph getMorph()
           
 int getMoveCost()
           
 boolean getTurnFinished()
          Will this creature add any more actions?
 java.util.Iterator getUsedLocatorKeys()
          Returns the iterator of all the keys of the locators that are currently in use (i.e. there is some attribute attached to them) by this creature.
 int move(java.util.List path)
           
 int move(java.awt.Point where, boolean approach)
          Add an action to the CreatureActionScheduler to move the creature to a location in the Maze.
 void setActionPoints(int actionPoints)
           
 boolean setCurrentWeapon(java.lang.String weapon)
           
 void setGeometryToStand()
          Set the visual representation to the one for standing still.
 void setHealthPoints(int healthPoints)
           
 void setLevel(Level level)
           
 void setLocation(java.awt.Point location)
           
protected  void setTurnFinished(boolean f)
          Set the flag that indicates that this Creature object will (and can't) add any more CreatureAction objects to the scheduler within it's current turn.
 boolean withinAttackDistance(Creature c)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ORDER_OK

public static final int ORDER_OK
the order was processed correctly

See Also:
Constant Field Values

ORDER_ERROR

public static final int ORDER_ERROR
the order couldn't be completed for some unknown reason

See Also:
Constant Field Values

ORDER_NOPATH

public static final int ORDER_NOPATH
the order couldn't be completed because there is no path to the given point

See Also:
Constant Field Values

ORDER_NOTENOUGHPOINTS

public static final int ORDER_NOTENOUGHPOINTS
the order couldn't be completed because this hero does not have enough action or other points

See Also:
Constant Field Values

ORDER_TILENOTTAKEN

public static final int ORDER_TILENOTTAKEN
the order couldn't be completed because the tile is not taken (e.g. in an attack order)

See Also:
Constant Field Values

ORDER_TILENOTFREE

public static final int ORDER_TILENOTFREE
the order couldn't be completed because the tile is taken (e.g. in a move order)

See Also:
Constant Field Values

ORDER_NOWEAPON

public static final int ORDER_NOWEAPON
See Also:
Constant Field Values

ORDER_NOTYOURTURN

public static final int ORDER_NOTYOURTURN
See Also:
Constant Field Values

ORDER_NOTENOUGHMAGIC

public static final int ORDER_NOTENOUGHMAGIC
See Also:
Constant Field Values
Constructor Detail

Creature

public Creature(CreatureTypeData type_data,
                CreatureSharedData points)
Constructs a creature (abstract).

Parameters:
points - The CreatureSharedData object of the creature.
Method Detail

setLocation

public void setLocation(java.awt.Point location)

setLevel

public void setLevel(Level level)

getLocation

public java.awt.Point getLocation()
Get the creature's current location in the maze.


getEndLocation

public java.awt.Point getEndLocation()
Get the location of the creature when all his actions that are currently queued in the action scheduler are finished.


move

public int move(java.awt.Point where,
                boolean approach)
Add an action to the CreatureActionScheduler to move the creature to a location in the Maze. Returns an error to the HeroControlComponent if the creature cannot access that tile.


move

public int move(java.util.List path)

attack

public int attack(java.awt.Point where,
                  int times)
Add an action to the CreatureActionScheduler to attack another creature in the maze. Returns an error to the HeroControlComponent if this action is not allowed.


attack

public int attack(Creature c,
                  int times)

withinAttackDistance

public boolean withinAttackDistance(Creature c)

findPath

public java.util.List findPath(java.awt.Point endPoint,
                               boolean approach)
An algorithm that looks for the shortest way to a certain tile in the Maze and returns an ArrayList of points, referring to the tiles upon which the Creature has to walk.


getLevel

public Level getLevel()

getCreatureSharedData

public CreatureSharedData getCreatureSharedData()

getActionPoints

public int getActionPoints()

setActionPoints

public void setActionPoints(int actionPoints)

getHealthPoints

public int getHealthPoints()

setHealthPoints

public void setHealthPoints(int healthPoints)

getBranchGroup

public javax.media.j3d.BranchGroup getBranchGroup()

attachAttribute

public void attachAttribute(CreatureAttribute attr,
                            java.lang.String location)
Attach an attribute, such as a weapon, to a certain locator in this creature. The attribute is first detached if it is already attached to this creature. Never attach an attribute to more than one Creature. If you don Java3D will give a MultipleParentException.


detachAttribute

public void detachAttribute(CreatureAttribute attr)
Detaches the given attribute from any locator in this creature.


getCreatureTypeData

public CreatureTypeData getCreatureTypeData()
Returns the type data of this creature. This object contains all data that is unique per kind of creature (knight, zombie, ...).


getUsedLocatorKeys

public java.util.Iterator getUsedLocatorKeys()
Returns the iterator of all the keys of the locators that are currently in use (i.e. there is some attribute attached to them) by this creature.


getLocatorGroup

public javax.media.j3d.TransformGroup getLocatorGroup(java.lang.String key)
Get the TransformGroup of the given locator, or return null if not in use. This should only be used by AttributeBehavior. This group has only one child: a BranchGroup, which also has only one child: attribute.getContentNode().


getCreatureAnimation

public CreatureAnimation getCreatureAnimation(java.lang.String key)
Get the creature animation with the given name (walk, fight, ...) of this creature.


createMorph

public javax.media.j3d.Morph createMorph(javax.media.j3d.GeometryArray[] keyframes)
Get the Morph object that contains the graphical representation for this creature.


getMorph

public javax.media.j3d.Morph getMorph()

setGeometryToStand

public void setGeometryToStand()
Set the visual representation to the one for standing still.


addActions

public void addActions()
Called by Level when it's this creatures turn. Calls addActionsInternal() that must be overriden by subclasses to add their actions.


addActionsInternal

protected abstract void addActionsInternal()
Must be overridden by subclasses to add actions to the scheduler. Call setTurnFinished(true) on Creature subclasses that are not controlled by the user.


setTurnFinished

protected void setTurnFinished(boolean f)
Set the flag that indicates that this Creature object will (and can't) add any more CreatureAction objects to the scheduler within it's current turn.


getTurnFinished

public boolean getTurnFinished()
Will this creature add any more actions?


finishTurn

public void finishTurn()

setCurrentWeapon

public boolean setCurrentWeapon(java.lang.String weapon)

getCurrentWeaponName

public java.lang.String getCurrentWeaponName()

getCurrentWeapon

public Weapon getCurrentWeapon()

getMoveCost

public int getMoveCost()

getDrinkCost

public int getDrinkCost()