vooga.engine.level
Class LevelField

java.lang.Object
  extended by com.golden.gamedev.object.PlayField
      extended by vooga.engine.core.PlayField
          extended by vooga.engine.level.LevelField

public class LevelField
extends PlayField

This class is a PlayField for the level that has all the rules built in, and overrides the update method to handle the updating of all the rules. It also decides whether the level/game should proceed or whether it's failed.


Constructor Summary
LevelField()
          Constructor
 
Method Summary
 void activateRule(Rule r)
          Activate a rule for this specific level
 void activateRule(java.lang.String s)
          Activate a rule for this specific level
 void addEvent(IEventHandler event)
           
 void addRule(java.lang.String n, Rule r)
          Add a rule to the current level
 void addRule(java.lang.String rulename, Rule rule, SpriteGroup[] obedients)
          add a rule to the current level, together with its associated
 void addSpriteGroup(Rule r, SpriteGroup g)
          add a spriteGroup to a rule
 void addSwitchConditoin(LevelSwitch ls)
          Add a condition that determines which level to switch to and what condition
 void checkLevelConditions()
          check for the conditions that decide the state of the level
 void deactivateRule(Rule r)
          Deactivate a rule for this specific level
 void deactivateRule(java.lang.String s)
          Deactivate a rule for this specific level
 boolean gameOver()
          Whether the game is lost
 boolean gameWon()
          Whether the game is won
 LevelField getNextLevelField()
          return the levelField for the next level and consequenctly updates the rules
 SpriteGroup[] getRuleSpriteGroup(Rule r)
          Get the SpriteGroups related to a specified rule.
 java.util.ArrayList<SpriteGroup> getRuleSpriteGroups()
          Get all the SpriteGroups the rules are specifying
 void initializeConditions(GameWonConditions gamewon, GameLostConditions gameLost, LevelSwitchingConditions levelSwitch)
          Initialize the conditions related to the game/level state
 void initializeEvents(EventPool pool)
          Initialize the events
 void initializeRules(java.util.HashMap<java.lang.String,Rule> rm)
          Initialize the rules from the specified rule map.
 void initializeRules(RulesCollection rc)
          Initializes the rules of the current level from the specified RulesCollection class.
 void removeEvent(IEventHandler event)
           
 void removeSwithCondition(LevelSwitch ls)
          remove the switch level condition
 boolean switchLevel()
           
 int switchToLevel()
           
 void update(long elapsedTime)
           
 
Methods inherited from class vooga.engine.core.PlayField
addColorBackground, addControl, addEventPool, addImageBackground, addMusic, addOverlayTracker, getBackground, getControl, getMusic, getOverlayTracker, getRule, setBackground
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LevelField

public LevelField()
Constructor

Method Detail

initializeRules

public void initializeRules(RulesCollection rc)
Initializes the rules of the current level from the specified RulesCollection class.

Parameters:
rc -

initializeEvents

public void initializeEvents(EventPool pool)
Initialize the events

Parameters:
pool -

addEvent

public void addEvent(IEventHandler event)
Overrides:
addEvent in class PlayField

removeEvent

public void removeEvent(IEventHandler event)

addSwitchConditoin

public void addSwitchConditoin(LevelSwitch ls)
Add a condition that determines which level to switch to and what condition

Parameters:
ls -

removeSwithCondition

public void removeSwithCondition(LevelSwitch ls)
remove the switch level condition

Parameters:
ls -

initializeRules

public void initializeRules(java.util.HashMap<java.lang.String,Rule> rm)
Initialize the rules from the specified rule map.

Parameters:
rm -

initializeConditions

public void initializeConditions(GameWonConditions gamewon,
                                 GameLostConditions gameLost,
                                 LevelSwitchingConditions levelSwitch)
Initialize the conditions related to the game/level state

Parameters:
gamewon -
gameLost -
levelProceed -
levelLost -

update

public void update(long elapsedTime)
Overrides:
update in class PlayField

getRuleSpriteGroups

public java.util.ArrayList<SpriteGroup> getRuleSpriteGroups()
Get all the SpriteGroups the rules are specifying

Returns:

getRuleSpriteGroup

public SpriteGroup[] getRuleSpriteGroup(Rule r)
Get the SpriteGroups related to a specified rule.

Parameters:
r -
Returns:

checkLevelConditions

public void checkLevelConditions()
check for the conditions that decide the state of the level


switchLevel

public boolean switchLevel()

switchToLevel

public int switchToLevel()

gameWon

public boolean gameWon()
Whether the game is won

Returns:

gameOver

public boolean gameOver()
Whether the game is lost

Returns:

getNextLevelField

public LevelField getNextLevelField()
return the levelField for the next level and consequenctly updates the rules

Returns:

addSpriteGroup

public void addSpriteGroup(Rule r,
                           SpriteGroup g)
add a spriteGroup to a rule

Parameters:
r -
g -

activateRule

public void activateRule(java.lang.String s)
Activate a rule for this specific level

Parameters:
r -

activateRule

public void activateRule(Rule r)
Activate a rule for this specific level

Parameters:
r -

deactivateRule

public void deactivateRule(java.lang.String s)
Deactivate a rule for this specific level

Parameters:
r -

deactivateRule

public void deactivateRule(Rule r)
Deactivate a rule for this specific level

Parameters:
r -

addRule

public void addRule(java.lang.String rulename,
                    Rule rule,
                    SpriteGroup[] obedients)
add a rule to the current level, together with its associated

Overrides:
addRule in class PlayField
Parameters:
rulename -
rule -
obedients -

addRule

public void addRule(java.lang.String n,
                    Rule r)
Add a rule to the current level

Parameters:
n -
r -