gizmoball.gui
Class WorldModel

java.lang.Object
  extended by java.util.Observable
      extended by gizmoball.gui.WorldModel

public class WorldModel
extends java.util.Observable

WorldModel is a wrapper for WorldState. WorldModel holds information about the WorldState in addition to information that may pertain to the game but not game play, such as key assignments. WorldModel is the central class that holds all the data necessary to save and load a game.


Constructor Summary
WorldModel(GameWorldState ws)
          Constructs a WorldModel with given WorldState ws.
 
Method Summary
 void addGizmosToMap(java.lang.Integer num, java.util.List<Gizmo> listGizmos)
          Adds list of Gizmos to the list of Gizmos activated by specified key press.
 void addTriggersToMap(java.lang.Integer num, java.util.List<Trigger> listTriggers)
          Adds list of triggers to the list of triggers activated by specified key press.
 void addTriggerToMap(java.lang.Integer num, Trigger trig)
          Adds trigger to the list of triggers activated by specified key press.
 boolean flipperAssigned()
          Checks to see if any keys have been mapped to Flippers.
 java.util.Map<java.lang.Integer,KeyableAction> getKeyMap()
          Returns the key mapping stored by this WorldModel.
 java.util.Map<java.lang.Integer,java.util.List<Gizmo>> getKeysToGizmos()
           
 java.util.Map<java.lang.Integer,java.util.List<Trigger>> getKeysToTriggers()
           
static java.lang.String getNameOfGameObject(GameObject g)
           
 java.util.List<Player> getPlayers()
           
 GameWorldState getWorldState()
          Returns private WorldState.
static boolean intersect(GameObject go1, GameObject go2)
           
static boolean isOverlapping(GamePlayModel gpm, GameObject gObj)
          Checks whether current GameObject overlaps with another.
 void readFromXMLandSetGizmos(int keyCode, java.util.List<Gizmo> listOfGizmos, boolean keyUp)
          Adds Gizmos to be activated by specified key.
 void readFromXMLandSetTriggers(int keyCode, java.util.List<Trigger> listOfTriggers, boolean keyUp)
          Adds Triggers to be activated by specified key.
 void resetKeys()
          Initializes keyToGizmos and keyToTriggers.
 void setDefaultFlipperKeys()
          Finds all the Flipper Gizmos and assigns 'z' and '/' keys to them.
 void setKeys(java.util.Map<java.lang.Integer,KeyableAction> keyMap)
          Sets the current key mapping to incoming key mapping.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorldModel

public WorldModel(GameWorldState ws)
Constructs a WorldModel with given WorldState ws. Initializes score.

Parameters:
ws -
Method Detail

getPlayers

public java.util.List<Player> getPlayers()
Returns:
score

resetKeys

public void resetKeys()
Initializes keyToGizmos and keyToTriggers.

Effects:
keyToGizmos, keyToTriggers

flipperAssigned

public boolean flipperAssigned()
Checks to see if any keys have been mapped to Flippers.

Returns:
True if and only if there exists a key assigned to a flipper.

setDefaultFlipperKeys

public void setDefaultFlipperKeys()
Finds all the Flipper Gizmos and assigns 'z' and '/' keys to them.


addGizmosToMap

public void addGizmosToMap(java.lang.Integer num,
                           java.util.List<Gizmo> listGizmos)
Adds list of Gizmos to the list of Gizmos activated by specified key press.

Parameters:
num -
listGizmos -

addTriggerToMap

public void addTriggerToMap(java.lang.Integer num,
                            Trigger trig)
Adds trigger to the list of triggers activated by specified key press.

Parameters:
num -
listGizmos -

addTriggersToMap

public void addTriggersToMap(java.lang.Integer num,
                             java.util.List<Trigger> listTriggers)
Adds list of triggers to the list of triggers activated by specified key press.

Parameters:
num -
listTriggers -

getKeyMap

public java.util.Map<java.lang.Integer,KeyableAction> getKeyMap()
Returns the key mapping stored by this WorldModel.

Returns:
keyToAction

getKeysToGizmos

public java.util.Map<java.lang.Integer,java.util.List<Gizmo>> getKeysToGizmos()
Returns:
Map> gizmoMap such that gizmoMap.get(key) returns the set of Gizmos activated by key

getKeysToTriggers

public java.util.Map<java.lang.Integer,java.util.List<Trigger>> getKeysToTriggers()
Returns:
Map> triggerMap such that triggerMap.get(key) returns the set of triggers activated by key

setKeys

public void setKeys(java.util.Map<java.lang.Integer,KeyableAction> keyMap)
Sets the current key mapping to incoming key mapping.

Parameters:
keyMap -

getWorldState

public GameWorldState getWorldState()
Returns private WorldState.

Returns:
ws

readFromXMLandSetGizmos

public void readFromXMLandSetGizmos(int keyCode,
                                    java.util.List<Gizmo> listOfGizmos,
                                    boolean keyUp)
Adds Gizmos to be activated by specified key.

Parameters:
keyCode -
list -
keyUp -
Effects:
keyToAction

readFromXMLandSetTriggers

public void readFromXMLandSetTriggers(int keyCode,
                                      java.util.List<Trigger> listOfTriggers,
                                      boolean keyUp)
Adds Triggers to be activated by specified key.

Parameters:
keyCode -
list -
keyUp -
Effects:
keyToAction

intersect

public static boolean intersect(GameObject go1,
                                GameObject go2)
Returns:
true if the bounding boxes intersect, false otherwise

getNameOfGameObject

public static java.lang.String getNameOfGameObject(GameObject g)
Parameters:
g -
Returns:
class name of Gizmo g

isOverlapping

public static boolean isOverlapping(GamePlayModel gpm,
                                    GameObject gObj)
Checks whether current GameObject overlaps with another.

Returns:
true if and only if currentGameObject is overlapping with another object, unless user allows overlap