org.globalse.arena.frag.game
Interface GameSetup

All Known Implementing Classes:
Sword

public interface GameSetup

The GameImplementation interface needs to be subclassed in order to implement a concrete FRAG-based game. In order to start a new game on the FRAG framework, it is recommended to initialize a GameManager by using the GameManagerRegistry method createGameManager(..). After that the initialization of the concrete GameSetup implementation takes place. By using the setSetup(..) of GameManager, the GameSetup is associated to the GameManager. The PeerConnectionServer needs to be created by using the newPeerConnectionServer(..) method of GameManager. When this is done, the methods for the real initialization of the concrete game e.g. initGame(..) (for starting a new game without joining/loading) or loadGame(..) can be called. As the framework uses "events" to talk between components (diffrent peers, components on the local peer) to notificate or keep the actual state on all peers, let's take a closer look at this. The pattern used to realize this, is the Observer Pattern. Therefore a sender (source) of an Event needs to implement the EventSource interface. Every EventSource descendant needs to provide an EventDistributor where event listeners can register themselves. An EventDistributor handles a list of recievers and disributes events to all of them. To recieve events an object needs to implement the EventSink interface and register itself at the EventDistributor. An additinal utility is the EventDispatcher, which is an EventSource and EventSink. It is referenced from GameManager and is the centralized component, all events pass. To register object "tree" for sending events: +register the EventDispatcher from GameManager at the EventDistributor of the tree To register object tree for recieving events: +register the tree at the EventDistributor of the EventDispather from GameManager In the konstructor of GameManager GameManager and ObjectManager are registrated as EventSource and EventSink. Also a PeerConnection is registrated as both. $Id: GameSetup.html,v 1.1 2003/02/12 18:06:19 schoecke Exp $


Method Summary
 void gameJoined(GameManager gameManager)
          is called when the sombody joins to the game over the network
 void initGame(GameManager gameManager)
          This code initializes the game
 void loadCharacter(GameManager gameManager, java.util.Vector v)
          loads a saved Character
 void loadGame(GameManager gameManager, java.util.Vector v)
          Method loadGame: loads a saved Game
 java.util.Vector saveCharacter(GameManager gameManager, java.lang.String name)
          saves a character
 java.util.Vector saveGame(GameManager gameManager)
          Method for saving a game.
 

Method Detail

initGame

public void initGame(GameManager gameManager)
This code initializes the game
Parameters:
gameManager - The instance of the GameManager
Preconditions:
GameManager != null
See Also:
GameManager

gameJoined

public void gameJoined(GameManager gameManager)
is called when the sombody joins to the game over the network
Parameters:
gameManager - The instance of the running GameManager
Preconditions:
GameManager != null
See Also:
GameManager

loadGame

public void loadGame(GameManager gameManager,
                     java.util.Vector v)
Method loadGame: loads a saved Game
Parameters:
gameManager - GameManager is the already gameManager.
v - : this Vector contains the information in the same order, as it has been saved

saveGame

public java.util.Vector saveGame(GameManager gameManager)
Method for saving a game.
Parameters:
gameManager - The instance of the running GameManager
Returns:
Vector all objects, need to serialized are stored in this vector

loadCharacter

public void loadCharacter(GameManager gameManager,
                          java.util.Vector v)
loads a saved Character
Parameters:
gameManager - The instance of the running GameManager
v - The Vector contains the information in the same order as it has been saved

saveCharacter

public java.util.Vector saveCharacter(GameManager gameManager,
                                      java.lang.String name)
saves a character
Parameters:
gameManager - The instance of the running GameManager
name - The nae of the character to save
Returns:
Vector all objects, need to serialized are stored in this vector



This page is hosted by the Chair for Applied Software Engineering of the Technische Universität München.
Imprint (Impressum)