Class ScoreSystemLayer

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

public class ScoreSystemLayer extends Object implements GameLayer
Score system layer is responsible for calculating the scores. The score calculation scheme can be changed by change the subscription of score observers.
  • Constructor Details

    • ScoreSystemLayer

      public ScoreSystemLayer()
  • Method Details

    • onGameStart

      public void onGameStart()
      Description copied from interface: GameLayer
      Define what to initialize before the game starts.
      Specified by:
      onGameStart in interface GameLayer
    • isGameEnd

      public boolean isGameEnd()
      Description copied from interface: GameLayer
      Get whether the game-over condition is met.
      Specified by:
      isGameEnd in interface GameLayer
      Returns:
      true iff game should end
    • notifyAllObservers

      public void notifyAllObservers(DataPackage dataPackage)
      Notify all score observers to calculate score incremented.
      Specified by:
      notifyAllObservers in interface GameLayer
      Parameters:
      dataPackage - - relavent data received from game
    • getScore

      public int getScore()
      Get the score incremented during one tick.
      Returns:
    • addScoreObserver

      public ScoreSystemLayer addScoreObserver(ScoreObserver scoreObserver)
      Add a score observer (Add a score calculation scheme).
      Parameters:
      scoreObserver -
      Returns:
      this