bubolo
 All Classes Namespaces Functions Variables Enumerator
Public Member Functions | Package Functions | List of all members
bubolo.world.GameWorld Class Reference
Inheritance diagram for bubolo.world.GameWorld:
bubolo.world.World

Public Member Functions

 GameWorld (int worldMapWidth, int worldMapHeight)
 
Entity getEntity (UUID id) throws GameLogicException
 
List< EntitygetEntities ()
 
void removeEntity (Entity e)
 
void removeEntity (UUID id) throws GameLogicException
 
int getMapWidth ()
 
int getMapHeight ()
 
void update ()
 

Package Functions

public< T extends Entity > T addEntity (Class< T > c) throws GameLogicException
 
public< T extends Entity > T addEntity (Class< T > c, UUID id) throws GameLogicException
 
public< T extends Entity > T addEntity (Class< T > c, ControllerFactory controllerFactory) throws GameLogicException
 
public< T extends Entity > T addEntity (Class< T > c, UUID id, ControllerFactory controllerFactory) throws GameLogicException, IllegalStateException
 

Detailed Description

The concrete implementation of the World interface. GameWorld is the sole owner of Entity objects.

Author
BU CS673 - Clone Productions

Definition at line 24 of file GameWorld.java.

Constructor & Destructor Documentation

bubolo.world.GameWorld.GameWorld ( int  worldMapWidth,
int  worldMapHeight 
)

Constructs the GameWorld object.

Parameters
worldMapWidththe width of the game world map.
worldMapHeightthe height of the game world map.

Definition at line 40 of file GameWorld.java.

Member Function Documentation

public<T extends Entity> T bubolo.world.GameWorld.addEntity ( Class< T >  c) throws GameLogicException
package

Performs the following actions:

  1. A new Entity of the specified type is created.
  2. The new Entity is added to the World
  3. A new Sprite is created and added to the Sprites list.
  4. One or more Controllers are created and added to the Controllers list.
Parameters
cthe entity's class object. For example, to create a new Tank, call this method using the following form: World.addEntity(Tank.class).
Returns
reference to the new entity.
Exceptions
GameLogicExceptionif the entity cannot be instantiated, or if the UUID already belongs to an entity.

Implements bubolo.world.World.

Definition at line 71 of file GameWorld.java.

Referenced by bubolo.world.GameWorld.addEntity().

public<T extends Entity> T bubolo.world.GameWorld.addEntity ( Class< T >  c,
UUID  id 
) throws GameLogicException
package
See Also
World::addEntity(Class)
Parameters
c
cthe entity's class object. For example, to create a new Tank, call this method using the following form: World.addEntity(Tank.class).
idthe UUID that will be used for the entity.
Returns
reference to the new entity.
Exceptions
GameLogicExceptionif the entity cannot be instantiated, or if the UUID already belongs to an entity.

Implements bubolo.world.World.

Definition at line 77 of file GameWorld.java.

References bubolo.world.GameWorld.addEntity().

public<T extends Entity> T bubolo.world.GameWorld.addEntity ( Class< T >  c,
ControllerFactory  controllerFactory 
) throws GameLogicException
package
See Also
World::addEntity(Class)
Parameters
cthe entity's class object. For example, to create a new Tank, call this method using the following form: World.addEntity(Tank.class).
controllerFactoryan object that implements the ControllerFactory interface. This should be used to override the default controller settings. In other words, use a controller factory to set different controller(s) for an entity than the default.
Returns
reference to the new entity. Note that the entity has already been added to the World.
Exceptions
GameLogicExceptionif the entity cannot be instantiated, or if the UUID already belongs to an entity.

Implements bubolo.world.World.

Definition at line 83 of file GameWorld.java.

References bubolo.world.GameWorld.addEntity().

public<T extends Entity> T bubolo.world.GameWorld.addEntity ( Class< T >  c,
UUID  id,
ControllerFactory  controllerFactory 
) throws GameLogicException, IllegalStateException
package
See Also
World::addEntity(Class)
Parameters
cthe entity's class object. For example, to create a new Tank, call this method using the following form: World.addEntity(Tank.class).
idthe UUID that will be used for the entity.
controllerFactoryan object that implements the ControllerFactory interface. This should be used to override the default controller settings. In other words, use a controller factory to set different controller(s) for an entity than the default.
Returns
reference to the new entity.
Exceptions
GameLogicExceptionif the entity cannot be instantiated, or if the UUID already belongs to an entity.

Implements bubolo.world.World.

Definition at line 89 of file GameWorld.java.

List<Entity> bubolo.world.GameWorld.getEntities ( )

Returns the list of all entities in the world. Ordering should not be assumed, and may change between calls.

Returns
the list of entities.

Implements bubolo.world.World.

Definition at line 64 of file GameWorld.java.

Entity bubolo.world.GameWorld.getEntity ( UUID  id) throws GameLogicException

Returns an entity from a user id. Throws a GameLogicException if the entity is not found.

Parameters
idthe entity's unique id.
Returns
the requested entity.
Exceptions
GameLogicExceptionif the entity is not found.

Implements bubolo.world.World.

Definition at line 52 of file GameWorld.java.

int bubolo.world.GameWorld.getMapHeight ( )

Returns the height of the game map.

Returns
the width of the game map.

Implements bubolo.world.World.

Definition at line 138 of file GameWorld.java.

int bubolo.world.GameWorld.getMapWidth ( )

Returns the width of the game map.

Returns
the width of the game map.

Implements bubolo.world.World.

Definition at line 132 of file GameWorld.java.

void bubolo.world.GameWorld.removeEntity ( Entity  e)

Removes an entity from the world. After this method is called, the specified entity will no longer be drawn or updated.

Parameters
ethe entity to remove.

Implements bubolo.world.World.

Definition at line 119 of file GameWorld.java.

Referenced by bubolo.world.GameWorld.removeEntity().

void bubolo.world.GameWorld.removeEntity ( UUID  id) throws GameLogicException

Removes an entity from the world. After this method is called, the specified entity will no longer be drawn or updated. Throws a GameLogicException if the entity is not found.

Parameters
idthe unique id of the entity to remove.
Exceptions
GameLogicExceptionif the entity is not found.

Implements bubolo.world.World.

Definition at line 126 of file GameWorld.java.

References bubolo.world.GameWorld.removeEntity().

void bubolo.world.GameWorld.update ( )

Updates the game world. Must be called once per game tick.

Implements bubolo.world.World.

Definition at line 144 of file GameWorld.java.