public final class GameWorld extends java.lang.Object implements IUpdateable
Constructor and Description |
---|
GameWorld() |
Modifier and Type | Method and Description |
---|---|
void |
addListener(java.lang.String mapName,
EnvironmentListener listener) |
void |
addLoadedListener(EnvironmentLoadedListener listener) |
void |
addLoadedListener(java.lang.String mapName,
EnvironmentLoadedListener listener) |
void |
addUnloadedListener(EnvironmentUnloadedListener listener) |
void |
addUnloadedListener(java.lang.String mapName,
EnvironmentUnloadedListener listener) |
void |
attach(java.lang.String mapName,
IUpdateable updateable) |
ICamera |
camera()
Gets the game's current
Camera . |
void |
clear()
Clears the currently active camera and environment, removes all previously loaded environments
and clears all listener lists.
|
boolean |
containsEnvironment(java.lang.String mapName)
Indicates whether this instance already contains an
Environment for the specified map name. |
void |
detach(java.lang.String mapName,
IUpdateable updateable) |
Environment |
environment()
Gets the game's current
Environment . |
Environment |
getEnvironment(IMap map)
Gets the environment that's related to the specified map.
This method implicitly creates a new Environment if necessary. |
Environment |
getEnvironment(java.lang.String mapName)
Gets the environment that's related to the specified mapName.
This method implicitly creates a new Environment if necessary. |
java.util.Collection<Environment> |
getEnvironments()
Gets all environments that are known to the game world.
|
int |
gravity() |
void |
loadEnvironment(Environment env)
Loads the specified
Environment and sets it as current environment of the game. |
Environment |
loadEnvironment(IMap map)
Loads the
Environment that is identified by the specified map and sets it as current environment of the game. |
Environment |
loadEnvironment(java.lang.String mapName)
Loads the
Environment that is identified by the specified map name and sets it as current environment of the game. |
void |
removeListener(java.lang.String mapName,
EnvironmentListener listener) |
void |
removeLoadedListener(EnvironmentLoadedListener listener) |
void |
removeLoadedListener(java.lang.String mapName,
EnvironmentLoadedListener listener) |
void |
removeUnloadedListener(EnvironmentUnloadedListener listener) |
void |
removeUnloadedListener(java.lang.String mapName,
EnvironmentUnloadedListener listener) |
Environment |
reset(IMap map)
Resets the previously loaded
Environment for the specified map so that it can be re-initiated upon the next access. |
Environment |
reset(java.lang.String mapName)
Resets the previously loaded
Environment for the specified map name so that it can be re-initiated upon the next access. |
void |
setCamera(ICamera cam)
Sets the active camera of the game.
|
void |
setGravity(int gravity)
Specify the general gravity that will be used as default value for all environments that are loaded.
|
void |
unloadEnvironment()
Unloads the current
Environment and sets it to null. |
void |
update()
This method is called by the game loop on all objects that need to update
their attributes.
|
public void update()
IUpdateable
update
in interface IUpdateable
public void addLoadedListener(EnvironmentLoadedListener listener)
public void removeLoadedListener(EnvironmentLoadedListener listener)
public void addUnloadedListener(EnvironmentUnloadedListener listener)
public void removeUnloadedListener(EnvironmentUnloadedListener listener)
public void addLoadedListener(java.lang.String mapName, EnvironmentLoadedListener listener)
public void removeLoadedListener(java.lang.String mapName, EnvironmentLoadedListener listener)
public void addUnloadedListener(java.lang.String mapName, EnvironmentUnloadedListener listener)
public void removeUnloadedListener(java.lang.String mapName, EnvironmentUnloadedListener listener)
public void addListener(java.lang.String mapName, EnvironmentListener listener)
public void removeListener(java.lang.String mapName, EnvironmentListener listener)
public void attach(java.lang.String mapName, IUpdateable updateable)
public void detach(java.lang.String mapName, IUpdateable updateable)
public ICamera camera()
Camera
.ICamera
public Environment environment()
Environment
.Environment
public int gravity()
public void clear()
public java.util.Collection<Environment> getEnvironments()
public Environment getEnvironment(java.lang.String mapName)
Environment
if necessary.mapName
- The map name by which the environment is identified.public Environment getEnvironment(IMap map)
Environment
if necessary.map
- The map by which the environment is identified.public boolean containsEnvironment(java.lang.String mapName)
Environment
for the specified map name.mapName
- The map name by which the environment is identified.public void loadEnvironment(Environment env)
Environment
and sets it as current environment of the game.
This implicitly unloads the previously loaded environment (if present).
The loaded environment can then be accessed via GameWorld#environment()
.
env
- The environment to be loaded.environment()
public Environment loadEnvironment(java.lang.String mapName)
Environment
that is identified by the specified map name and sets it as current environment of the game.
This implicitly unloads the previously loaded environment (if present).
The loaded environment can then be accessed via GameWorld#environment()
.
mapName
- The map name by which the environment is identified.environment()
,
loadEnvironment(Environment)
public Environment loadEnvironment(IMap map)
Environment
that is identified by the specified map and sets it as current environment of the game.
This implicitly unloads the previously loaded environment (if present).
The loaded environment can then be accessed via GameWorld#environment()
.
map
- The map by which the environment is identified.environment()
,
loadEnvironment(Environment)
public void unloadEnvironment()
Environment
and sets it to null.public Environment reset(java.lang.String mapName)
Environment
for the specified map name so that it can be re-initiated upon the next access.
This can be used if one wants to completely reset the state of a level to its initial state. It'll just throw away the current environment instance and reload a new one upon the next access.
mapName
- The map name by which the environment is identified.getEnvironment(String)
,
reset(IMap)
public Environment reset(IMap map)
Environment
for the specified map so that it can be re-initiated upon the next access.
This can be used if one wants to completely reset the state of a level to its initial state. It'll just throw away the current environment instance and reload a new one upon the next access.
map
- The map by which the environment is identified.getEnvironment(String)
,
reset(IMap)
public void setCamera(ICamera cam)
cam
- The new camera to be set.public void setGravity(int gravity)
IMobileEntity
.gravity
- The default gravity for all environments.IMobileEntity.getVelocity()