com.brackeen.javagamebook.scripting
Class ScriptManager

java.lang.Object
  extended bycom.brackeen.javagamebook.scripting.ScriptManager

public class ScriptManager
extends java.lang.Object

The ScriptManager class handles the invoking of scripted methods. Scripted methods can add functionality to different GameObject notifications for each unique object. For example, the methods for collision notifications for the "player" object are:

    playerFloorCollision()
    playerWallCollision()
    playerCeilingCollision()
    
Likewise, if "player" collides with the "box" object, these methods are called:
    player_boxCollision()
    player_boxTouch()
    player_boxRelease()
    
Also, the initLevel() method is called on startup.


Nested Class Summary
 class ScriptManager.ScriptedListener
          A GameObjectEventListener that delgates calls to scripted methods.
 
Constructor Summary
ScriptManager()
           
 
Method Summary
 boolean hasScripts(GameObject object)
          Checks to see if the specified game object has any scripts (check to see if any scripted method starts with the object's name).
 void invoke(java.lang.String methodName)
          Invokes the specified scripted method.
 boolean isMethod(java.lang.String methodName)
          Returns true if the specified method name is an exsting scripted method.
 void setupLevel(GameObjectManager gameObjectManager, GameTaskManager gameTaskManager, java.lang.String[] scriptFiles)
          Sets up the ScriptManager for a level.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptManager

public ScriptManager()
Method Detail

setupLevel

public void setupLevel(GameObjectManager gameObjectManager,
                       GameTaskManager gameTaskManager,
                       java.lang.String[] scriptFiles)
Sets up the ScriptManager for a level. The list of script files are executed, and every object in the GameObjectManager that has a name are added as named variables for the scripts. Also, the scripted method initLevel() is called if it exists.


hasScripts

public boolean hasScripts(GameObject object)
Checks to see if the specified game object has any scripts (check to see if any scripted method starts with the object's name).


isMethod

public boolean isMethod(java.lang.String methodName)
Returns true if the specified method name is an exsting scripted method.


invoke

public void invoke(java.lang.String methodName)
Invokes the specified scripted method.