|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.rico.adventure.script.trigger.AbstractTrigger
public abstract class AbstractTrigger
This is the base class for every trigger in the game.
Note: By convention you have to define two methods for
each trigger in your corresponding script file. The method names
have to be exactly like this:
scriptId+"onEnter()" and scriptId+"OnExit()". The script id value
has been specified in the constructor. Simply concat "OnEnter()" and
"OnExit()" to it.
Example: Image the specified script id parameter in the
constructor was "trigger". The two correponding methods would
be called triggerOnEnter()
and triggerOnExit()
Constructor Summary | |
---|---|
AbstractTrigger(java.lang.String scriptId,
float x,
float z)
Creates a new trigger area that has no candidates for firering the trigger assigned initially. |
|
AbstractTrigger(java.lang.String scriptId,
float x,
float z,
AbstractCharacter c)
Creates a new trigger area that reacts only to the specified character. |
|
AbstractTrigger(java.lang.String scriptId,
float x,
float z,
java.util.List<AbstractCharacter> candiates)
Creates a new trigger area with a list of characters that can fire the trigger. |
Method Summary | |
---|---|
void |
addCandidate(AbstractCharacter c)
Adds a candiate for firering the trigger. |
abstract void |
draw(javax.media.opengl.GL gl)
Draws the trigger area to the ground. |
java.util.List<AbstractCharacter> |
getCandidates()
Returns a list with all the candiates for firering the trigger. |
Color4f |
getColor()
Returns the color of the trigger's visalisation mesh. |
java.lang.String |
getScriptId()
Returns the reference id for this entity which is used in a script file. |
float |
getX()
Returns the trigger's x-coordinate. |
float |
getZ()
Returns the trigger's z-coordinate. |
boolean |
hasBeenCalledEnterMethod()
Determines if the "on enter method" has already been called. |
boolean |
hasBeenCalledExitMethod()
Determines if the "on exit method" has already been called. |
abstract boolean |
isCandiateOnTrigger()
Determines if at least one candiate character is within the trigger area. |
boolean |
isEnabled()
Determines whether or not the trigger is enabled. |
void |
removeCandidate(AbstractCharacter c)
Removes a candiate for firering the trigger from the list. |
void |
setCalledEnterMethod(boolean called)
Sets a flag if the "on enter method" has been called. |
void |
setCalledExitMethod(boolean called)
Sets a flag if the "on exit method" has been called. |
void |
setColor(Color4f color)
Sets the color of the trigger visualisation mesh. |
void |
setEnabled(boolean enable)
Enables or disables the trigger. |
void |
setPosition(float x,
float z)
Sets the position (x,z) of the trigger. |
void |
setScriptId(java.lang.String id)
Sets the script id of this trigger to the new string value. |
void |
setX(float x)
Sets the trigger's x-coordinate. |
void |
setZ(float z)
Sets the trigger's z-coordinate. |
void |
update(long elapsedTime)
Updates the trigger state. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractTrigger(java.lang.String scriptId, float x, float z)
scriptId
- id for reference purposes in script filesx
- x-coordinate of the triggerz
- z-coordinate of the triggerpublic AbstractTrigger(java.lang.String scriptId, float x, float z, AbstractCharacter c)
scriptId
- id for reference purposes in script filesx
- x-coordinate of the triggerz
- z-coordinate of the triggerc
- only character that can fire the triggerpublic AbstractTrigger(java.lang.String scriptId, float x, float z, java.util.List<AbstractCharacter> candiates)
scriptId
- id for reference purposes in script filesx
- x-coordinate of the triggerz
- z-coordinate of the triggercandiates
- Method Detail |
---|
public void setColor(Color4f color)
color
- color of the trigger meshpublic Color4f getColor()
public void addCandidate(AbstractCharacter c)
c
- candiate for firering the triggerpublic void removeCandidate(AbstractCharacter c)
c
- candiate for firering the triggerpublic java.util.List<AbstractCharacter> getCandidates()
public java.lang.String getScriptId()
java.lang.NullPointerException
- Occurs when no id has been specified for the
entity.public void setScriptId(java.lang.String id)
id
- new script id for the triggerpublic float getX()
public void setX(float x)
x
- new x-coordinate of the triggerpublic float getZ()
public void setZ(float z)
z
- new z-coordinate of the triggerpublic void setPosition(float x, float z)
x
- mew x-coordinate of the triggerz
- mew z-coordinate of the triggerpublic void setEnabled(boolean enable)
enable
- set trigger enabled? --> true=yes, false=falsepublic boolean isEnabled()
public boolean hasBeenCalledEnterMethod()
public void setCalledEnterMethod(boolean called)
called
- has been called on enter method? --> true=yes, false=nopublic boolean hasBeenCalledExitMethod()
public void setCalledExitMethod(boolean called)
called
- has been called on eexit method? --> true=yes, false=nopublic abstract boolean isCandiateOnTrigger()
public void update(long elapsedTime)
elapsedTime
- time between two framespublic abstract void draw(javax.media.opengl.GL gl)
gl
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |