edu.gatech.cs2335.lemmings.engine
Class Level

java.lang.Object
  extended byedu.gatech.cs2335.lemmings.engine.Level
All Implemented Interfaces:
ICleanable

public class Level
extends java.lang.Object
implements ICleanable

This is a playable level. version MAGIC.2 (2004-04-20) - Jose Update Fixed memory leaks version MAGIC - (2004-04-15) - Jose Update Added code to handle lemmings going offscreen no performance hit for catching ArrayIndexOOB

Author:
Vladimir Urazov

Constructor Summary
Level()
          Creates a new Level instance.
 
Method Summary
 void addPrettySprite(PrettySprite ps)
          Adds a new pretty sprite to the llist of pretty sprites.
 void assignJobToLemming(Lemming l)
          This function will be called when a lemming has been clicked.
 void cleanUp()
          Describe cleanUp method here.
 void decreaseLemmingFlow()
          Decrease the lemming flow rate by 1
 Level duplicate()
          Creates a duplicate copy of this level for multiplayer games
 Lemming findLemmingAt(java.awt.Point coordinates)
          Returns the lemming at given world coordinates, or NULL if no such lemming exists.
 java.lang.String getActiveJobId()
          Get the value of activeJobId.
 java.util.List getActiveLemmings()
          Access method for the activeLemmings property.
 LevelData getData()
          Access method for the data property.
 int getJobsRemaining(java.lang.String id)
          Returns the number of jobs with the specified id remaining.
 int getLemmingFlow()
          Accessor for lemmingFlow rate
 java.util.List getLemmingHeaven()
          Access method for the lemmingHeaven property.
 int getLemmingsDead()
          Access method for the lemmingsDead property.
 int getLemmingsReleased()
          Access method for the lemmingsReleased property.
 int getLemmingsSaved()
          Access method for the lemmingsSaved property.
 java.util.List getLevelPortals()
          Access method for the levelPortals property.
 Map getMap()
          Access method for the map property.
 int getNumLemmings()
          accessor
 java.util.List getPendingLemmings()
          Access method for the pendingLemmings property.
 java.util.List getPrettySprites()
          Access method for the prettySprites property.
 long getTimeIncrement()
          Get the value of timeIncrement.
 long getTimeRemaining()
          Access method for the timeRemaining property.
 void increaseLemmingFlow()
          Increases the lemming flow rate by 1
 boolean isLevelOver()
          Returns true if the level is over.
 boolean isPaused()
          Describe isPaused method here.
 void killLemming(Lemming lemming, boolean saved)
          Kills the lemming passed in.
 void killPrettySprite(PrettySprite ps)
          Kills the pretty sprite.
 void nukeEmALL()
          Makes all the lemmings explode.
 void pause()
          Pauses the level.
 void releaseLemming()
          Releases a new lemming from the release point.
 void setActiveJobId(java.lang.String v)
          Set the value of activeJobId.
 void setData(LevelData aData)
          Sets the value of the data property.
 void setLemmingFlow(int rate)
          Sets lemmingFlow
 void setLemmingsDead(int aLemmingsDead)
          Sets the value of the lemmingsDead property.
 void setLemmingsReleased(int aLemmingsReleased)
          Sets the value of the lemmingsReleased property.
 void setLemmingsSaved(int aLemmingsSaved)
          Sets the value of the lemmingsSaved property.
 void setMap(Map aMap)
          Sets the value of the map property.
 void setNumberOfLemmings(int num)
          Describe setNumberOfLemmings method here.
 void setNumLemmings(int i)
          mutator
 void setTimeIncrement(long v)
          Set the value of timeIncrement.
 void setTimeRemaining(long aTimeRemaining)
          Sets the value of the timeRemaining property.
 void stopLevel()
          This function will be called when the level should be stopped - either when the time has run out, or all the lemmings are off the map.
 void unpause()
          Unpauses the level.
 void updateLevel()
          Runs through the lemmings and updates each one that needs updating.
 void updateLevel(AbstractMessage message)
          Updates the level with the message received from the network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Level

public Level()
Creates a new Level instance.

Method Detail

getTimeIncrement

public long getTimeIncrement()
Get the value of timeIncrement.

Returns:
value of timeIncrement.

setTimeIncrement

public void setTimeIncrement(long v)
Set the value of timeIncrement.

Parameters:
v - Value to assign to timeIncrement.

getMap

public Map getMap()
Access method for the map property.

Returns:
the current value of the map property

setMap

public void setMap(Map aMap)
Sets the value of the map property.

Parameters:
aMap - the new value of the map property

getPendingLemmings

public java.util.List getPendingLemmings()
Access method for the pendingLemmings property.

Returns:
the current value of the pendingLemmings property

getActiveLemmings

public java.util.List getActiveLemmings()
Access method for the activeLemmings property.

Returns:
the current value of the activeLemmings property

getLemmingHeaven

public java.util.List getLemmingHeaven()
Access method for the lemmingHeaven property.

Returns:
the current value of the lemmingHeaven property

getLevelPortals

public java.util.List getLevelPortals()
Access method for the levelPortals property.

Returns:
the current value of the levelPortals property

getPrettySprites

public java.util.List getPrettySprites()
Access method for the prettySprites property.

Returns:
the current value of the prettySprites property

getTimeRemaining

public long getTimeRemaining()
Access method for the timeRemaining property.

Returns:
the current value of the timeRemaining property

setTimeRemaining

public void setTimeRemaining(long aTimeRemaining)
Sets the value of the timeRemaining property.

Parameters:
aTimeRemaining - the new value of the timeRemaining property

getLemmingsSaved

public int getLemmingsSaved()
Access method for the lemmingsSaved property.

Returns:
the current value of the lemmingsSaved property

setLemmingsSaved

public void setLemmingsSaved(int aLemmingsSaved)
Sets the value of the lemmingsSaved property.

Parameters:
aLemmingsSaved - the new value of the lemmingsSaved property

getLemmingsDead

public int getLemmingsDead()
Access method for the lemmingsDead property.

Returns:
the current value of the lemmingsDead property

setLemmingsDead

public void setLemmingsDead(int aLemmingsDead)
Sets the value of the lemmingsDead property.

Parameters:
aLemmingsDead - the new value of the lemmingsDead property

getLemmingsReleased

public int getLemmingsReleased()
Access method for the lemmingsReleased property.

Returns:
the current value of the lemmingsReleased property

setLemmingsReleased

public void setLemmingsReleased(int aLemmingsReleased)
Sets the value of the lemmingsReleased property.

Parameters:
aLemmingsReleased - the new value of the lemmingsReleased property

getData

public LevelData getData()
Access method for the data property.

Returns:
the current value of the data property

setNumberOfLemmings

public void setNumberOfLemmings(int num)
Describe setNumberOfLemmings method here.

Parameters:
num - an int value

setData

public void setData(LevelData aData)
Sets the value of the data property.

Parameters:
aData - the new value of the data property

getActiveJobId

public java.lang.String getActiveJobId()
Get the value of activeJobId.

Returns:
value of activeJobId.

setActiveJobId

public void setActiveJobId(java.lang.String v)
Set the value of activeJobId.

Parameters:
v - Value to assign to activeJobId.

getJobsRemaining

public int getJobsRemaining(java.lang.String id)
Returns the number of jobs with the specified id remaining.

Parameters:
id - a String value
Returns:
an int value

addPrettySprite

public void addPrettySprite(PrettySprite ps)
Adds a new pretty sprite to the llist of pretty sprites.

Parameters:
ps - a PrettySprite value

killPrettySprite

public void killPrettySprite(PrettySprite ps)
Kills the pretty sprite. Note that this actually sends the pretty sprite to lemming heaven instead of outright killing it, since we would like to avoid garbage collection during the game, if possible.

Parameters:
ps - a PrettySprite value

pause

public void pause()
Pauses the level.


unpause

public void unpause()
Unpauses the level.


isPaused

public boolean isPaused()
Describe isPaused method here.

Returns:
boolean , true for paused, false for unpaused

stopLevel

public void stopLevel()
This function will be called when the level should be stopped - either when the time has run out, or all the lemmings are off the map.


isLevelOver

public boolean isLevelOver()
Returns true if the level is over. A level is considered over if the time has run out, or if there are no pending or live lemmings.

Returns:
boolean , whether or not the level is over

updateLevel

public void updateLevel()
Runs through the lemmings and updates each one that needs updating. Also, if it is time to release a new lemming, does so.


updateLevel

public void updateLevel(AbstractMessage message)
Updates the level with the message received from the network.

Parameters:
message - mes

releaseLemming

public void releaseLemming()
Releases a new lemming from the release point.


nukeEmALL

public void nukeEmALL()
Makes all the lemmings explode.


killLemming

public void killLemming(Lemming lemming,
                        boolean saved)
Kills the lemming passed in.

Parameters:
lemming - The lemming to be killed.
saved - If true, then the lemming will be counted as saved. Otherwise, it will count as dead.

assignJobToLemming

public void assignJobToLemming(Lemming l)
This function will be called when a lemming has been clicked.

Parameters:
l - a Lemming value

findLemmingAt

public Lemming findLemmingAt(java.awt.Point coordinates)
Returns the lemming at given world coordinates, or NULL if no such lemming exists.

Parameters:
coordinates - a Point value
Returns:
a Lemming value

cleanUp

public void cleanUp()
Describe cleanUp method here.

Specified by:
cleanUp in interface ICleanable

getLemmingFlow

public int getLemmingFlow()
Accessor for lemmingFlow rate

Returns:
int , lemmingFlow rate

increaseLemmingFlow

public void increaseLemmingFlow()
Increases the lemming flow rate by 1


decreaseLemmingFlow

public void decreaseLemmingFlow()
Decrease the lemming flow rate by 1


getNumLemmings

public int getNumLemmings()
accessor

Returns:
int

setNumLemmings

public void setNumLemmings(int i)
mutator

Parameters:
i - value for numLemmings

setLemmingFlow

public void setLemmingFlow(int rate)
Sets lemmingFlow

Parameters:
rate - , new flowrate

duplicate

public Level duplicate()
Creates a duplicate copy of this level for multiplayer games

Returns:
Level