de.rico.adventure.structure
Class Room

java.lang.Object
  extended by de.rico.adventure.structure.Room

public class Room
extends java.lang.Object

This class specifies a single room (game location) in the adventure game.

Author:
Frank Bruns

Constructor Summary
Room(InputManager input)
          Creates a new room with the specified input manager object.
Room(java.lang.String roomFile, InputManager input)
          Creates a new room with the specified parameters.
 
Method Summary
 void addCameraPerspective(CameraPerspective cam, int id)
          Adds a camera perspective to the room.
 void addCharacter(NonPlayerCharacter character)
          Adds a non player character to the room.
 void addController(ControllerIface cntr)
          Adds an controller to the room.
 void addEntryPoint(EntryPoint ep)
          Adds an entry point to the room.
 void addHotspot(AbstractInteractiveHotspot hs)
          Adds an interactive hotspot to the room.
 void addItem(Item item)
          Adds an item to the room.
 void addLight(LightIface light)
          Adds the specified light to the room.
 void addParticleEffect(AbstractParticleEffect effect)
          Adds a particle the effect to the room's particle effect container.
 void addProp(Prop prop)
          Adds a prop, a passive mesh which is only used for constructing the setting of the room.
 void addTexProjector(TextureProjector proj)
          Adds a texture projector to the room.
 void addTrigger(AbstractTrigger trigger)
          Adds a trigger to the room.
 void draw(javax.media.opengl.GL gl)
          Draws the room and its content.
 java.util.LinkedHashMap<java.lang.Integer,CameraPerspective> getCameraPerspectives()
          Retuns the map of camera perspectives that is assigned to this room.
 Chapter getChapter()
          Returns the chapter this room belongs to.
 NonPlayerCharacter getCharacter(java.lang.String scriptId)
          Returns the nonplayer character with the specified id
 java.util.ArrayList<NonPlayerCharacter> getCharacters()
          Returns the non player characters that are assigned to the room.
 java.util.List<ControllerIface> getControllers()
          Returns the controllers of the room.
 AbstractEntity getEntityByMesh(AbstractMesh mesh)
          Returns the entity that corresponds to the specified mesh object.
 EntryPoint getEntryPoint(java.lang.String scriptId)
          Returns the entry point that correspond to the specified script id.
 java.util.List<EntryPoint> getEntryPoints()
          Returns the entry points of the room.
 AbstractGroundMesh getGround()
          Returns the ground mesh, if one has been added to the room, else null.
 AbstractInteractiveHotspot getHotspot(int screenX, int screenY)
          Returns the first found hotspot that lies under the specified screen coordinates. if none was found this method returns null.
 AbstractInteractiveHotspot getHotspot(java.lang.String scriptId)
          Returns a hotspot by its script id.
 java.util.List<AbstractInteractiveHotspot> getHotspots()
          Returns a list containing the hotspots of the room.
 int getInitialCamPerspective()
          Returns the initial camera perspective of the room.
 java.util.ArrayList<Item> getItems()
          Returns the items that are assigned to the room.
 LightIface getLight(int nr)
          Returns the light (child of AbstractLight only!)
 java.util.LinkedList<LightIface> getLights()
          Returns the lights of the room.
 MeshContainer getMeshes()
          Returns the mesh container with meshes of this room.
 java.util.List<AbstractParticleEffect> getParticleEffects()
          Returns a list containing the particle effects of the room.
 PlayableCharacter getPlayer()
          Returns the playable character from this room.
 java.util.ArrayList<Prop> getProps()
          Returns the props of this room.
 java.lang.String getScriptFile()
          Returns the path to the script file that was assigned to this room.
 java.lang.String getScriptId()
          Returns the script id (which is the room's id in the chapter, too) of the room.
 ScriptInterpreter getScriptInterpreter()
          Returns the script interpreter used by this room.
 PositionalLight getShadowReferenceLight()
          Returns the shadow reference light for this room.
 java.util.List<TextureProjector> getTexProjectors()
          Returns the texture projectors of the room.
 AbstractTrigger getTrigger(java.lang.String triggerName)
          Returns the trigger that corresponds to the specified name (which is its script id).
 java.util.List<AbstractTrigger> getTriggers()
          Returns the list of triggers of this room.
 boolean hasBeenEnteredAlready()
          Determines whether or not the room has been entered already.
 void removeAllCameraPerspectives()
          Removes all camera perspectives that were assigned to this room.
 void removeAllCharacters()
          Removes every non player character from the room.
 void removeAllEntryPoints()
          Removes all entry points from the room.
 void removeAllItems()
          Removes every item from the room.
 void removeAllLights()
          Removes every light from the room.
 void removeAllProps()
          Removes every prop from the room.
 void removeAllTriggers()
          Removes every trigger from the room.
 void removeCameraPerspective(int id)
          Removes the camera perspective which corresponds to the specified id from the room.
 void removeCharacter(NonPlayerCharacter character)
          Removes a non player character from the room.
 void removeController(ControllerIface cntr)
          Removes the specified controller from the room.
 void removeControllers()
          Removes all controllers from the room.
 void removeEntryPoint(EntryPoint ep)
          Removes the specified entry point from the room.
 void removeHotspot(AbstractInteractiveHotspot hs)
          Removes the specified hotspot from the room.
 void removeHotspot(java.lang.String scriptId)
          Removes the hotspot from the room which corresponds to the specified script id.
 void removeItem(Item item)
          Removes an item from the room.
 void removeLight(LightIface light)
          Removes the specified light from the room
 void removeParticleEffect(AbstractParticleEffect effect)
          Removes the specified particle effect from the room's particle container.
 void removePlayer()
          Removes the playable character from the room.
 void removeProp(Prop prop)
           
 void removeTexProjector(TextureProjector proj)
          Removes a texture projector from the room.
 void removeTrigger(AbstractTrigger trigger)
          Removes a trigger from the room.
 void removeTrigger(java.lang.String triggerName)
          Removes a trigger from the room by its name.
 void setInitialCamPerspective(int initialCam)
          Sets the initial camera perspective of the room.
 void setPlayer(PlayableCharacter player)
          Assigns the playable character to the room.
 void setPlayer(PlayableCharacter player, java.lang.String entryPointId)
          Assigns the playable character to the room.
 void setScriptFile(java.lang.String scriptFile)
          Sets the script file of the room.
 void setScriptId(java.lang.String scriptId)
          Sets the script id of the room.
 void setShadowReferenceLight(PositionalLight refLight)
          Sets the positional light that ought to be used as a reference light for shadow casting techniques.
 void update(long elapsedTime)
          Updates everything in the room.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Room

public Room(InputManager input)
Creates a new room with the specified input manager object.

Parameters:
input - input manager object

Room

public Room(java.lang.String roomFile,
            InputManager input)
Creates a new room with the specified parameters. The script id is used for referencingthis room in a chapter.

Parameters:
roomFile - path to the .room file for the room
input - input manager object
Method Detail

setScriptId

public void setScriptId(java.lang.String scriptId)
Sets the script id of the room.

Parameters:
scriptId - script id for the room

getScriptId

public java.lang.String getScriptId()
Returns the script id (which is the room's id in the chapter, too) of the room.

Returns:
script id of the room

getScriptInterpreter

public ScriptInterpreter getScriptInterpreter()
Returns the script interpreter used by this room. This method actually is a shortcut to the getChapter().getScriptInterpreter() call.

Returns:
the script interpreter used by this room

setScriptFile

public void setScriptFile(java.lang.String scriptFile)
Sets the script file of the room.

Parameters:
scriptFile - script file for the room

getScriptFile

public java.lang.String getScriptFile()
Returns the path to the script file that was assigned to this room.

Returns:
path to script for this room

hasBeenEnteredAlready

public boolean hasBeenEnteredAlready()
Determines whether or not the room has been entered already.

Returns:
has the room been entered already? --> true=yes, false=no

setInitialCamPerspective

public void setInitialCamPerspective(int initialCam)
Sets the initial camera perspective of the room.

Parameters:
initialCam - nr of the initial camera perspective

getInitialCamPerspective

public int getInitialCamPerspective()
Returns the initial camera perspective of the room.

Returns:
nr of the initial camera perspective of the room

getChapter

public Chapter getChapter()
Returns the chapter this room belongs to. The assignment cannot be done manually. It gets assigned in the Chapter class when the room is assigned to a chapter.

Returns:
chapter this room belongs to

addTrigger

public void addTrigger(AbstractTrigger trigger)
Adds a trigger to the room.

Parameters:
trigger - trigger to add to the room

removeTrigger

public void removeTrigger(AbstractTrigger trigger)
Removes a trigger from the room.


removeTrigger

public void removeTrigger(java.lang.String triggerName)
Removes a trigger from the room by its name.


getTrigger

public AbstractTrigger getTrigger(java.lang.String triggerName)
Returns the trigger that corresponds to the specified name (which is its script id). If none is found this method returns null.

Parameters:
triggerName - name of the trigger to return.
Returns:
trigger corresponding to the specified trigger name

getTriggers

public java.util.List<AbstractTrigger> getTriggers()
Returns the list of triggers of this room.

Returns:
triggers of this room

removeAllTriggers

public void removeAllTriggers()
Removes every trigger from the room.


addLight

public void addLight(LightIface light)
Adds the specified light to the room.

Parameters:
light - light to add to the room

removeLight

public void removeLight(LightIface light)
Removes the specified light from the room

Parameters:
light - light to remove from the room

getLights

public java.util.LinkedList<LightIface> getLights()
Returns the lights of the room.

Returns:
lights of the room

getLight

public LightIface getLight(int nr)
Returns the light (child of AbstractLight only!) that has the specified light nr. If none was found it returns null.

Parameters:
nr - number of the light to seek
Returns:
the sought light with the specified light number

removeAllLights

public void removeAllLights()
Removes every light from the room.


setShadowReferenceLight

public void setShadowReferenceLight(PositionalLight refLight)
Sets the positional light that ought to be used as a reference light for shadow casting techniques.

Parameters:
refLight - shadow reference light

getShadowReferenceLight

public PositionalLight getShadowReferenceLight()
Returns the shadow reference light for this room. If none was assigned yet the method returns null.

Returns:
shadow reference light, or null.

addTexProjector

public void addTexProjector(TextureProjector proj)
Adds a texture projector to the room.

Parameters:
proj - texture projector to add

removeTexProjector

public void removeTexProjector(TextureProjector proj)
Removes a texture projector from the room.

Parameters:
proj - texture projector to remove

getTexProjectors

public java.util.List<TextureProjector> getTexProjectors()
Returns the texture projectors of the room.

Returns:
list with texture projectors

addCameraPerspective

public void addCameraPerspective(CameraPerspective cam,
                                 int id)
Adds a camera perspective to the room.

Parameters:
cam - camera perspective to add
id - reference id for the perspective

removeCameraPerspective

public void removeCameraPerspective(int id)
Removes the camera perspective which corresponds to the specified id from the room.

Parameters:
id - id of the perspective to remove from the room

removeAllCameraPerspectives

public void removeAllCameraPerspectives()
Removes all camera perspectives that were assigned to this room.


getCameraPerspectives

public java.util.LinkedHashMap<java.lang.Integer,CameraPerspective> getCameraPerspectives()
Retuns the map of camera perspectives that is assigned to this room.

Returns:
map of camera perspective of this room

addEntryPoint

public void addEntryPoint(EntryPoint ep)
Adds an entry point to the room.

Parameters:
ep - entry point to add

removeEntryPoint

public void removeEntryPoint(EntryPoint ep)
Removes the specified entry point from the room.

Parameters:
ep - entry point to remove

removeAllEntryPoints

public void removeAllEntryPoints()
Removes all entry points from the room.


getEntryPoint

public EntryPoint getEntryPoint(java.lang.String scriptId)
Returns the entry point that correspond to the specified script id. If none was found null is returned.

Parameters:
scriptId - script id of seeked entry point
Returns:
entry point that correspond to the script id

getEntryPoints

public java.util.List<EntryPoint> getEntryPoints()
Returns the entry points of the room.

Returns:
the room's entry points

addController

public void addController(ControllerIface cntr)
Adds an controller to the room.

Parameters:
cntr - controller to add

removeController

public void removeController(ControllerIface cntr)
Removes the specified controller from the room.

Parameters:
cntr - controller to remove

removeControllers

public void removeControllers()
Removes all controllers from the room.


getControllers

public java.util.List<ControllerIface> getControllers()
Returns the controllers of the room.

Returns:
the room's controllers

setPlayer

public void setPlayer(PlayableCharacter player)
Assigns the playable character to the room.

Parameters:
player - playable character

setPlayer

public void setPlayer(PlayableCharacter player,
                      java.lang.String entryPointId)
Assigns the playable character to the room. The player will be positioned and rotated according to the entry point which corresponds to the specified entry point script id

Parameters:
player - playable character
entryPointId - script id of the entry point to take as reference for positioning and rotating the player

getPlayer

public PlayableCharacter getPlayer()
Returns the playable character from this room.

Returns:
playable character of the room

removePlayer

public void removePlayer()
Removes the playable character from the room.


addCharacter

public void addCharacter(NonPlayerCharacter character)
Adds a non player character to the room.

Parameters:
character - non player character to add to the room

removeCharacter

public void removeCharacter(NonPlayerCharacter character)
Removes a non player character from the room.

Parameters:
character - character to remove from the room

getCharacters

public java.util.ArrayList<NonPlayerCharacter> getCharacters()
Returns the non player characters that are assigned to the room.

Returns:
characters in the room.

getCharacter

public NonPlayerCharacter getCharacter(java.lang.String scriptId)
Returns the nonplayer character with the specified id

Parameters:
scriptId -
Returns:
the NPC with the specified id

removeAllCharacters

public void removeAllCharacters()
Removes every non player character from the room.


addItem

public void addItem(Item item)
Adds an item to the room.

Parameters:
item - item to add to the room

removeItem

public void removeItem(Item item)
Removes an item from the room.

Parameters:
item - item to remove from the room

getItems

public java.util.ArrayList<Item> getItems()
Returns the items that are assigned to the room.

Returns:
items in the room.

removeAllItems

public void removeAllItems()
Removes every item from the room.


addProp

public void addProp(Prop prop)
Adds a prop, a passive mesh which is only used for constructing the setting of the room.
Note: If you're adding a ground mesh you will be able to access it by the getGround() method.

Parameters:
prop - prop for the setting

removeProp

public void removeProp(Prop prop)

getProps

public java.util.ArrayList<Prop> getProps()
Returns the props of this room.

Returns:
props of this room

removeAllProps

public void removeAllProps()
Removes every prop from the room.


addParticleEffect

public void addParticleEffect(AbstractParticleEffect effect)
Adds a particle the effect to the room's particle effect container.

Parameters:
effect - particle effect to add to the room

removeParticleEffect

public void removeParticleEffect(AbstractParticleEffect effect)
Removes the specified particle effect from the room's particle container.

Parameters:
effect - particle effect to remove from the room.

getParticleEffects

public java.util.List<AbstractParticleEffect> getParticleEffects()
Returns a list containing the particle effects of the room.

Returns:
particle effects of the room

addHotspot

public void addHotspot(AbstractInteractiveHotspot hs)
Adds an interactive hotspot to the room.

Parameters:
hs - interactive hotspot to add

removeHotspot

public void removeHotspot(AbstractInteractiveHotspot hs)
Removes the specified hotspot from the room.

Parameters:
hs - interactive hotspot to remove

removeHotspot

public void removeHotspot(java.lang.String scriptId)
Removes the hotspot from the room which corresponds to the specified script id.

Parameters:
scriptId - script id of the hotspot to remove

getHotspot

public AbstractInteractiveHotspot getHotspot(java.lang.String scriptId)
Returns a hotspot by its script id. If none was found this method returns null.

Parameters:
scriptId - seeked hotspot's script id
Returns:
hotspot that corresponds to the specified script id

getHotspot

public AbstractInteractiveHotspot getHotspot(int screenX,
                                             int screenY)
Returns the first found hotspot that lies under the specified screen coordinates. if none was found this method returns null.

Parameters:
screenX - screen x-coordinate
screenY - screen y-coordinate
Returns:
hotspot under the screen coordinates

getHotspots

public java.util.List<AbstractInteractiveHotspot> getHotspots()
Returns a list containing the hotspots of the room.

Returns:
list of hotspots

getGround

public AbstractGroundMesh getGround()
Returns the ground mesh, if one has been added to the room, else null.

Returns:
the room's ground mesh, else null.

getMeshes

public MeshContainer getMeshes()
Returns the mesh container with meshes of this room.

Returns:
mesh container of the room

getEntityByMesh

public AbstractEntity getEntityByMesh(AbstractMesh mesh)
Returns the entity that corresponds to the specified mesh object. If none is found the method returns null.

Parameters:
mesh - mesh that belongs to the seeked entity.
Returns:
entity that is based on the specified mesh

update

public void update(long elapsedTime)
Updates everything in the room.

Parameters:
elapsedTime - time between two frames

draw

public void draw(javax.media.opengl.GL gl)
Draws the room and its content.

Parameters:
gl -