location
Class GameLocation

java.lang.Object
  extended by location.GameLocation
All Implemented Interfaces:
java.io.Serializable

public class GameLocation
extends java.lang.Object
implements java.io.Serializable

This class reprsents a location with all its contents.

Author:
Frank Bruns
See Also:
Serialized Form

Constructor Summary
GameLocation(java.lang.String name, java.lang.String bshName, java.lang.String xmlFile, java.lang.String bshScriptFile, java.lang.String pathBGImg, java.lang.String imgWalkable, java.lang.String bgMusicFile, int scale, com.golden.gamedev.engine.BaseLoader bsLoader, com.golden.gamedev.engine.BaseInput bsInput, com.golden.gamedev.engine.BaseAudio bsSound, com.golden.gamedev.engine.BaseAudio bsMusic)
          Creates a new game location with the specified parameters
 
Method Summary
 void addCharacter(NPCSprite character)
          Adds a character to the location.
 void addExit(java.lang.String name, java.lang.String bshName, double x, double y, int width, int height, double newX, double newY, boolean usable, GameLocation destination)
          Adds an exit to the game location with the specified parameters
 void addInteractiveHotspot(InteractiveHotspot hs)
          Adds an interactive hotspot to the game location
 void addItem(Item item)
          Adds an item to the game location
 void addPlayer(Player player)
          Adds the player character to the game location
 void addProp(Prop prop)
          Adds a prop to the list of props of this game location
 java.lang.String getBshName()
          Returns the beanshell name for this game location
 java.util.ArrayList<LocationExit> getExits()
          Returns the list of exits of this game location
 java.util.ArrayList<InteractiveHotspot> getInteractiveHotspots()
          Returns a list with the interactive hotspots of the game location
 java.util.ArrayList<Item> getItems()
          Return a list with all the items of the game location
 java.lang.String getMusicFileName()
          Returns the path+file name of the background music theme of this game location
 java.lang.String getName()
          Returns the name of the game location
 java.util.ArrayList<NPCSprite> getNonPlayerCharacters()
          Returns a list containing the characters of the location.
 SearchGrid getPathSearchGrid()
          Returns the path search grid with the current state of the grid
 Player getPlayer()
          Returns the player object in the game location
 java.util.ArrayList<Prop> getProps()
          Return a list with all the props of the game location
 float getScaling()
          Returns the scaling factor for the game location's characters
 java.lang.String getScriptFileName()
          Returns the path+filename of the beanshell script file assigned to this game location
 com.golden.gamedev.engine.BaseAudio getSoundRenderer()
          Returns the object responsible for playing sounds of the game location
 java.lang.String getXMLFileName()
          Returns the path+filename of the xml file assigned to this game location
 void initSearchGrid()
          Initializes the search grid for pathfinding.
 boolean isActive()
          Determines wheter this is the location that is currently shown
 void playMusic(boolean loop)
          Starts to play the assigned background music for this game location
 void playMusic(java.lang.String musicPath, boolean loop)
          Starts to play the specified music file
 void playSound(java.lang.String filePath)
          Plays a sampled sound file once
 void removeCharacter(NPCSprite character)
          Removes a non player character from the game location
 void removeItem(Item item)
          Removes an item from the game location, for example if the player picked it up
 void removePlayer()
          Removes the player from this game location
 void render(java.awt.Graphics2D g)
          Renders the content of the game loaction
 void setActive(boolean active)
          Enables or disables the game loaction.
 void setBackground(java.lang.String pathBGImg)
          Sets the background of the game location to the specified background
 void setIntermissionScreenDiabled()
          Disables the intermission screen.
 void setIntermissionScreenEnabled(java.lang.String imgPath)
          Sets an intermission screen that can be rendered instead of the usual game location content
 void update(long elapsedTime)
          Updates the content of the game location
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GameLocation

public GameLocation(java.lang.String name,
                    java.lang.String bshName,
                    java.lang.String xmlFile,
                    java.lang.String bshScriptFile,
                    java.lang.String pathBGImg,
                    java.lang.String imgWalkable,
                    java.lang.String bgMusicFile,
                    int scale,
                    com.golden.gamedev.engine.BaseLoader bsLoader,
                    com.golden.gamedev.engine.BaseInput bsInput,
                    com.golden.gamedev.engine.BaseAudio bsSound,
                    com.golden.gamedev.engine.BaseAudio bsMusic)
Creates a new game location with the specified parameters

Parameters:
name - name of the game location
bshName - beanshell name for useage in beanshell script files
xmlFile - path+file name of the assigned xml file
bshScriptFile - path+filename to beanshell script file for this game location. Call setUpBshScript() after the game loactions has been fully instantiated with characters and items
pathBGImg - path to the background image for the loaction
bgMusicFile - path+file name to music file
scale - sacling factor for the characters in the location
bsLoader -
bsInput -
bsSound -
Method Detail

getXMLFileName

public java.lang.String getXMLFileName()
Returns the path+filename of the xml file assigned to this game location

Returns:
path+filename of the xml file

getScriptFileName

public java.lang.String getScriptFileName()
Returns the path+filename of the beanshell script file assigned to this game location

Returns:
path+filename of the beanshell script file

getMusicFileName

public java.lang.String getMusicFileName()
Returns the path+file name of the background music theme of this game location

Returns:
path+file name of the background music theme

getName

public java.lang.String getName()
Returns the name of the game location

Returns:
name of the game location

getBshName

public java.lang.String getBshName()
Returns the beanshell name for this game location

Returns:
beanshell name for this game location

getScaling

public float getScaling()
Returns the scaling factor for the game location's characters

Returns:
scaling factor for the characters

setBackground

public void setBackground(java.lang.String pathBGImg)
Sets the background of the game location to the specified background

Parameters:
pathBGImg - path+filename of the new background image

setIntermissionScreenEnabled

public void setIntermissionScreenEnabled(java.lang.String imgPath)
Sets an intermission screen that can be rendered instead of the usual game location content

Parameters:
imgPath - path+filename to the intermission screen image

setIntermissionScreenDiabled

public void setIntermissionScreenDiabled()
Disables the intermission screen. After calling this method no intermission screen will be rendered until newly set.


initSearchGrid

public void initSearchGrid()
Initializes the search grid for pathfinding. Call this method after all items and interactive hotspots have been added to the game location object.


getPathSearchGrid

public SearchGrid getPathSearchGrid()
Returns the path search grid with the current state of the grid

Returns:
path search grid

playMusic

public void playMusic(boolean loop)
Starts to play the assigned background music for this game location

Parameters:
loop - loop the music? --> true=yes, false=no

playMusic

public void playMusic(java.lang.String musicPath,
                      boolean loop)
Starts to play the specified music file

Parameters:
musicPath - path+filename to music file to play
loop - loop the music? --> true=yes, false=no

playSound

public void playSound(java.lang.String filePath)
Plays a sampled sound file once

Parameters:
filePath - path+filename of the sound file to play

getSoundRenderer

public com.golden.gamedev.engine.BaseAudio getSoundRenderer()
Returns the object responsible for playing sounds of the game location

Returns:
object responsible for playing sounds

addItem

public void addItem(Item item)
Adds an item to the game location

Parameters:
item - item to add to the game location

removeItem

public void removeItem(Item item)
Removes an item from the game location, for example if the player picked it up

Parameters:
item - the item to remove

getItems

public java.util.ArrayList<Item> getItems()
Return a list with all the items of the game location

Returns:
list with items of the location

getProps

public java.util.ArrayList<Prop> getProps()
Return a list with all the props of the game location

Returns:
list with props of the location

addProp

public void addProp(Prop prop)
Adds a prop to the list of props of this game location

Parameters:
prop - prop to add to the game location

addCharacter

public void addCharacter(NPCSprite character)
Adds a character to the location. Only add non player characters. Use addPlayer to add the player character to the game location

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

removeCharacter

public void removeCharacter(NPCSprite character)
Removes a non player character from the game location

Parameters:
character - the character to remove

addInteractiveHotspot

public void addInteractiveHotspot(InteractiveHotspot hs)
Adds an interactive hotspot to the game location

Parameters:
hs - interactive hotspot to add to the game location

getInteractiveHotspots

public java.util.ArrayList<InteractiveHotspot> getInteractiveHotspots()
Returns a list with the interactive hotspots of the game location

Returns:
interactive hotspots of the game location

getNonPlayerCharacters

public java.util.ArrayList<NPCSprite> getNonPlayerCharacters()
Returns a list containing the characters of the location. This list only contains non player characters

Returns:
list with characters of the location

getPlayer

public Player getPlayer()
Returns the player object in the game location

Returns:
player object

addPlayer

public void addPlayer(Player player)
Adds the player character to the game location

Parameters:
player - player object

removePlayer

public void removePlayer()
Removes the player from this game location


addExit

public void addExit(java.lang.String name,
                    java.lang.String bshName,
                    double x,
                    double y,
                    int width,
                    int height,
                    double newX,
                    double newY,
                    boolean usable,
                    GameLocation destination)
Adds an exit to the game location with the specified parameters

Parameters:
name - name of the exit
bshName - beanshell name for the location exit
x - x-coordinate
y - y-coordinate
width - width of the exit
height - height of the exit
newX - new x-coordinate for the player
newY - new y-coordinate for the player
usable - determines if the exit can be initially used
destination - the destination game location this exit leads to

getExits

public java.util.ArrayList<LocationExit> getExits()
Returns the list of exits of this game location

Returns:
list of exits of this game location

isActive

public boolean isActive()
Determines wheter this is the location that is currently shown

Returns:
is location shown? --> true=yes, false=no

setActive

public void setActive(boolean active)
Enables or disables the game loaction. If it is set to active, it is the currently shown one. If it is set to not active, the game location is not the shown one anymore

Parameters:
active - activate location (true) or deactive location (false)

update

public void update(long elapsedTime)
Updates the content of the game location

Parameters:
elapsedTime - time between two frames

render

public void render(java.awt.Graphics2D g)
Renders the content of the game loaction

Parameters:
g -