Class TimedLayer

java.lang.Object
sac.model.gamemodes.TimedLayer
All Implemented Interfaces:
GameLayer

public class TimedLayer extends Object implements GameLayer
Timed the game. End the game when the elapsed time is greater than the set value.
  • Constructor Details

    • TimedLayer

      public TimedLayer()
  • Method Details

    • onGameStart

      public void onGameStart()
      Start a timer.
      Specified by:
      onGameStart in interface GameLayer
    • isGameEnd

      public boolean isGameEnd()
      Check if the elapsed time is greater than the set time.
      Specified by:
      isGameEnd in interface GameLayer
      Returns:
      true iff the elapsed time is greater than the set time
    • setTimer

      public void setTimer(String timer)
      Set a time limit to the game.
      Parameters:
      timer - - the time limit in the form of "mm:ss"
    • getCurrentTime

      public String getCurrentTime()
      Get the elapsed time since game starts.
      Returns:
      the elapsed time in the form of "mm:ss"
    • notifyAllObservers

      public void notifyAllObservers(DataPackage dataPackage)
      Do nothing. Unrelated to this game layer.
      Specified by:
      notifyAllObservers in interface GameLayer
      Parameters:
      dataPackage - - relavent data received from game