vooga.gameEngine.core
Class GameManager

java.lang.Object
  extended by vooga.gameEngine.core.GameManager

public class GameManager
extends java.lang.Object

Class responsible for communication between the game and the engine. An instance of the class is added to the game by the engine. It can then be used to get game specific controllers and add and remove objects from the game. This class should be used by the AbstractGame whenever an object needs to be added by the game.

Author:
Jacob Harer, Scott Brothers

Constructor Summary
GameManager(GameEngine engine, java.util.Collection<? extends java.util.EventListener> gameStatusListeners)
          Creates a GameManager object provided the GameEngine it will communicate with and the collection of EventListeners with which to communicate important information.
 
Method Summary
 boolean addAllGeneralItems(java.util.Collection<? extends java.lang.Object> items)
          Adds all the new Objects as general items for the game.
 boolean addAllLevelItems(java.util.Collection<? extends java.lang.Object> items)
          Adds all the given Objects as level items.
 boolean addAllPersistentItems(java.util.Collection<? extends java.lang.Object> items)
          Adds all the given Objects as persistent items.
 boolean addGeneralItem(java.lang.Object item)
          Adds a new Object as a general item.
 boolean addLevelItem(java.lang.Object item)
          Adds a new Object as a level item.
 boolean addPersistentItem(java.lang.Object item)
          Adds a new Object as a persistent item.
 AIController getAIController()
          Method for getting the AIController.
 java.util.List<Collidable<? extends Collidable<?>>> getAllCollidables()
          Method for getting all the current Collidable items.
 java.util.Collection<java.lang.Object> getAllGeneralItems()
          Method for getting all the current Objects in the game.
 java.util.Collection<java.lang.Object> getAllLevelItems()
          Method for getting all the current level Objects.
 java.util.List<PhysicalItem> getAllNonCollidablePhysicalItems()
          Method for getting all the current PhysicalItems that are not Collidable.
 java.util.Collection<java.lang.Object> getAllPersistentItems()
          Method for getting all the current persistent Objects.
 java.util.List<PhysicalItem> getAllPhysicalItems()
          Method for getting all the current PhysicalItems.
 java.util.Set<Renderable> getAllRenderables()
          Method for getting all the current Renderable items.
 CameraController getCamera()
          Gets the the camera used by this game.
 HumanController getHumanController()
          Method for getting the HumanController.
 java.util.Collection<java.lang.Object> getInitialState()
          Loads the initial state of a level back into a Collection of Objects.
 NetworkController getNetworkController()
          Method for getting the NetworkController.
 double getScore()
          Simple getter method for the score of the AbstractGame at the time of the method being called.
 SoundController getSoundController()
          Method for getting the SoundController.
 TimingController getTimingController()
          Method for getting the TimingController.
 boolean pauseGameLoop()
          Attempts to pause the game loop.
 void reachedAchievement(java.lang.String achievement)
          Method to be called when an achievement has been made during game play.
 boolean removeAllGeneralItems()
          Removes all of the loaded, non-persistent Objects from the game.
 boolean removeAllItems()
          Removes ALL loaded Objects from their relevant collections.
 boolean removeAllItems(java.util.Collection<? extends java.lang.Object> items)
          Removes all given Objects from their relevant collections.
 boolean removeAllLevelItems()
          Removes all of the non-persistent level Objects.
 boolean removeAllPersistentItems()
          Removes all of the persistent Objects.
 boolean removeItem(java.lang.Object item)
          Removes the given Object from all relevant collections.
 void resumeGameLoop()
          Attempts to resume the game loop.
 void setCamera(CameraController c)
          Sets the camera to the CameraController specific to this game.
 void setScore(double score)
          Simple setter method for the score of the AbstractGame.
 void storeInitialState(java.util.Collection<java.lang.Object> items)
          Saves the initial state of a level in a ByteArrayOutputStream.
 void updateScore()
          Notifies all relevant listeners of the latest score.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GameManager

public GameManager(GameEngine engine,
                   java.util.Collection<? extends java.util.EventListener> gameStatusListeners)
Creates a GameManager object provided the GameEngine it will communicate with and the collection of EventListeners with which to communicate important information.

Parameters:
engine - the GameEngine this GameManager is associated with
gameStatusListeners - the Collection of EventListeners to be notified of important information regarding the game status, such as the score or any achievements made
Method Detail

addGeneralItem

public boolean addGeneralItem(java.lang.Object item)
Adds a new Object as a general item.

Parameters:
item - to be added
Returns:
true if the collection of general items is altered

addLevelItem

public boolean addLevelItem(java.lang.Object item)
Adds a new Object as a level item.

Parameters:
item - to be added
Returns:
true if the collection of level items is altered

addPersistentItem

public boolean addPersistentItem(java.lang.Object item)
Adds a new Object as a persistent item. A persistent item is one that will not be removed by calls to removeAllGeneralItems() or removeAllLevelItems().

Parameters:
item - to be added
Returns:
true if the collection of persistent items is altered

addAllGeneralItems

public boolean addAllGeneralItems(java.util.Collection<? extends java.lang.Object> items)
Adds all the new Objects as general items for the game.

Parameters:
items - to be added
Returns:
true if the collection of general items is altered

addAllLevelItems

public boolean addAllLevelItems(java.util.Collection<? extends java.lang.Object> items)
Adds all the given Objects as level items.

Parameters:
items - to be added
Returns:
true if the collection of level items is altered

addAllPersistentItems

public boolean addAllPersistentItems(java.util.Collection<? extends java.lang.Object> items)
Adds all the given Objects as persistent items. A persistent item is one that will not be removed by calls to removeAllGeneralItems() or removeAllLevelItems().

Parameters:
items - to be added
Returns:
true if the collection of persistent items is altered

removeItem

public boolean removeItem(java.lang.Object item)
Removes the given Object from all relevant collections. Note that calling this method directly will attempt to remove an Object from the overall collection of general items, the collection of level items, AND the collection of persistent items.

Parameters:
item - to be removed
Returns:
true if the collection of general items is modified

removeAllItems

public boolean removeAllItems(java.util.Collection<? extends java.lang.Object> items)
Removes all given Objects from their relevant collections. Note that calling this method directly will attempt to remove the Objects from the overall collection of general items, the collection of level items, AND the collection of persistent items.

Parameters:
items - to be removed
Returns:
true if the collection of general items is modified

removeAllItems

public boolean removeAllItems()
Removes ALL loaded Objects from their relevant collections.

Returns:
true if the collection of general items is modified
See Also:
removeAllItems(Collection)

removeAllGeneralItems

public boolean removeAllGeneralItems()
Removes all of the loaded, non-persistent Objects from the game.

Returns:
true if the collection of general items is modified

removeAllLevelItems

public boolean removeAllLevelItems()
Removes all of the non-persistent level Objects.

Returns:
true if the collection of general items is modified

removeAllPersistentItems

public boolean removeAllPersistentItems()
Removes all of the persistent Objects.

Returns:
true if the collection of general items is modified

getAllGeneralItems

public java.util.Collection<java.lang.Object> getAllGeneralItems()
Method for getting all the current Objects in the game.

Returns:
the Collection of Objects currently stored.

getAllCollidables

public java.util.List<Collidable<? extends Collidable<?>>> getAllCollidables()
Method for getting all the current Collidable items.

Returns:
the List of Collidable items currently stored.

getAllPhysicalItems

public java.util.List<PhysicalItem> getAllPhysicalItems()
Method for getting all the current PhysicalItems.

Returns:
the List of PhysicalItems currently stored.

getAllNonCollidablePhysicalItems

public java.util.List<PhysicalItem> getAllNonCollidablePhysicalItems()
Method for getting all the current PhysicalItems that are not Collidable.

Returns:
the List of non-Collidable PhysicalItems currently stored.

getAllLevelItems

public java.util.Collection<java.lang.Object> getAllLevelItems()
Method for getting all the current level Objects.

Returns:
the Collection of all level Objects currently stored.

getAllRenderables

public java.util.Set<Renderable> getAllRenderables()
Method for getting all the current Renderable items.

Returns:
the List of Renderable items currently stored.

getAllPersistentItems

public java.util.Collection<java.lang.Object> getAllPersistentItems()
Method for getting all the current persistent Objects.

Returns:
the Collection of all persistent Object s currently stored.

getTimingController

public TimingController getTimingController()
Method for getting the TimingController.

Returns:
the TimingController for the game

getNetworkController

public NetworkController getNetworkController()
Method for getting the NetworkController.

Returns:
the NetworkController for the game

getHumanController

public HumanController getHumanController()
Method for getting the HumanController.

Returns:
the HumanController for the game

getAIController

public AIController getAIController()
Method for getting the AIController.

Returns:
the AIController for the game

getSoundController

public SoundController getSoundController()
Method for getting the SoundController.

Returns:
the SoundController for the game

setCamera

public void setCamera(CameraController c)
Sets the camera to the CameraController specific to this game.

Parameters:
c - is the CameraController used by the game

getCamera

public CameraController getCamera()
Gets the the camera used by this game.

Returns:
the CameraController used by the game

storeInitialState

public void storeInitialState(java.util.Collection<java.lang.Object> items)
Saves the initial state of a level in a ByteArrayOutputStream. When a new level is loaded, this method is called by the AbstractGame so that the level can be reloaded in the event of a restart. NOTE: NOT CURRENTLY CALLED

Parameters:
items - Objects to be stored

getInitialState

public java.util.Collection<java.lang.Object> getInitialState()
Loads the initial state of a level back into a Collection of Objects. Useful in the event that the game needs to restart the current level. NOTE: NOT CURRENTLY CALLED

Returns:
the Collection of Objects that defines a particular level.

getScore

public double getScore()
Simple getter method for the score of the AbstractGame at the time of the method being called.

Returns:
the game's score

setScore

public void setScore(double score)
Simple setter method for the score of the AbstractGame.

Parameters:
score - of the game

pauseGameLoop

public boolean pauseGameLoop()
Attempts to pause the game loop.

Returns:
true if the game loop was successfully paused; false otherwise

resumeGameLoop

public void resumeGameLoop()
Attempts to resume the game loop.


reachedAchievement

public void reachedAchievement(java.lang.String achievement)
Method to be called when an achievement has been made during game play. This method will notify all relevant listeners that this has occurred.

Parameters:
achievement - that has been reached

updateScore

public void updateScore()
Notifies all relevant listeners of the latest score.