Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.rico.adventure.script.trigger
Class AbstractTrigger

    java.lang.Object
      de.rico.adventure.script.trigger.AbstractTrigger

Direct Known Subclasses:
  CircleTriggerArea, RectTriggerArea

    public abstract class AbstractTrigger

extends java.lang.Object

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()`

Author:
  Frank Bruns

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

### AbstractTrigger

    public AbstractTrigger(java.lang.String scriptId,
                           float x,
                           float z)

  Creates a new trigger area that has no candidates for firering the trigger assigned initially.

  Parameters:
    `scriptId` - id for reference purposes in script files
    `x` - x-coordinate of the trigger
    `z` - z-coordinate of the trigger

### AbstractTrigger

    public AbstractTrigger(java.lang.String scriptId,
                           float x,
                           float z,
                           AbstractCharacter c)

  Creates a new trigger area that reacts only to the specified character.

  Parameters:
    `scriptId` - id for reference purposes in script files
    `x` - x-coordinate of the trigger
    `z` - z-coordinate of the trigger
    `c` - only character that can fire the trigger

### AbstractTrigger

    public 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.

  Parameters:
    `scriptId` - id for reference purposes in script files
    `x` - x-coordinate of the trigger
    `z` - z-coordinate of the trigger
    `candiates` -

Method Detail

### setColor

    public void setColor(Color4f color)

  Sets the color of the trigger visualisation mesh.

  Parameters:
    `color` - color of the trigger mesh

### getColor

    public Color4f getColor()

  Returns the color of the trigger's visalisation mesh.

  Returns:
    color of the trigger's mesh

### addCandidate

    public void addCandidate(AbstractCharacter c)

  Adds a candiate for firering the trigger.

  Parameters:
    `c` - candiate for firering the trigger

### removeCandidate

    public void removeCandidate(AbstractCharacter c)

  Removes a candiate for firering the trigger from the list.

  Parameters:
    `c` - candiate for firering the trigger

### getCandidates

    public java.util.List<AbstractCharacter> getCandidates()

  Returns a list with all the candiates for firering the trigger.

  Returns:
    candiates for firering the trigger

### getScriptId

    public java.lang.String getScriptId()

  Returns the reference id for this entity which is used in a script file.

  Returns:
    reference id in a script file
  Throws:
    `java.lang.NullPointerException` - Occurs when no id has been specified for the entity.

### setScriptId

    public void setScriptId(java.lang.String id)

  Sets the script id of this trigger to the new string value.

  Parameters:
    `id` - new script id for the trigger

### getX

    public float getX()

  Returns the trigger's x-coordinate.

  Returns:
    x-coordinate of the trigger

### setX

    public void setX(float x)

  Sets the trigger's x-coordinate.

  Parameters:
    `x` - new x-coordinate of the trigger

### getZ

    public float getZ()

  Returns the trigger's z-coordinate.

  Returns:
    z-coordinate of the trigger

### setZ

    public void setZ(float z)

  Sets the trigger's z-coordinate.

  Parameters:
    `z` - new z-coordinate of the trigger

### setPosition

    public void setPosition(float x,
                            float z)

  Sets the position (x,z) of the trigger.

  Parameters:
    `x` - mew x-coordinate of the trigger
    `z` - mew z-coordinate of the trigger

### setEnabled

    public void setEnabled(boolean enable)

  Enables or disables the trigger. If the trigger is disabled it will not react to firering candidates anymore.

  Parameters:
    `enable` - set trigger enabled? --> true=yes, false=false

### isEnabled

    public boolean isEnabled()

  Determines whether or not the trigger is enabled.

  Returns:
    is trigger enabled? --> true=yes, false=no

### hasBeenCalledEnterMethod

    public boolean hasBeenCalledEnterMethod()

  Determines if the "on enter method" has already been called.

  Returns:
    on enter method has been called? --> true=yes, false=no

### setCalledEnterMethod

    public void setCalledEnterMethod(boolean called)

  Sets a flag if the "on enter method" has been called.

  Parameters:
    `called` - has been called on enter method? --> true=yes, false=no

### hasBeenCalledExitMethod

    public boolean hasBeenCalledExitMethod()

  Determines if the "on exit method" has already been called.

  Returns:
    on exit method has been called? --> true=yes, false=no

### setCalledExitMethod

    public void setCalledExitMethod(boolean called)

  Sets a flag if the "on exit method" has been called.

  Parameters:
    `called` - has been called on eexit method? --> true=yes, false=no

### isCandiateOnTrigger

    public abstract boolean isCandiateOnTrigger()

  Determines if at least one candiate character is within the trigger area.

  Returns:
    is character on trigger? --> true=yes, false=no

### update

    public void update(long elapsedTime)

  Updates the trigger state. This method monitors, if a character has entered or leaved the trigger area and invokes the enter or exit method accordingly.

  Parameters:
    `elapsedTime` - time between two frames

### draw

    public abstract void draw(javax.media.opengl.GL gl)

  Draws the trigger area to the ground.

  Parameters:
    `gl` -

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD