Class City

java.lang.Object
  extended by greenfoot.World
      extended by City

public class City
extends greenfoot.World

'City' acts as a container for all objects / "Actors" in the game (incl. map, HUD, etc.)

Since:
2012-02-11
Version:
v1.0
Author:
Felix Mo

Constructor Summary
City(java.lang.String name, java.lang.String path)
          Constructs a City.
 
Method Summary
 void didIncrementDate()
           This method is called when date is incremented (every 1 sec).
 void didMoveMapTo(int x, int y)
           This method is called when the map is moved.
 void didMoveViewportTo(int x, int y)
           This method is called when the minimap viewport has been moved.
static City getInstance()
          Returns an instance of City.
 void hideOverlay()
          Hides the overlay.
 Hint hint()
          Returns the active Hint.
 MenuBar menuBar()
          Returns an instance of MenuBar.
 void removeHint()
          Removes the active hint from view.
 int score()
          Returns the city's current score.
 void setHint(Hint hint)
          Sets the active hint.
 void setScore(int value)
          Sets the city's score.
 void showOverlay()
          Shows an overlay to fade out the screen.
Methods inherited from class greenfoot.World
act, addObject, getBackground, getCellSize, getColorAt, getHeight, getObjects, getObjectsAt, getWidth, numberOfObjects, removeObject, removeObjects, repaint, setActOrder, setBackground, setBackground, setPaintOrder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

City

public City(java.lang.String name,
            java.lang.String path)
Constructs a City.

Method Detail

didIncrementDate

public void didIncrementDate()

This method is called when date is incremented (every 1 sec).

This method tells Data to write the latest statistics to the database and hints to the JVM to perform GC every 10 secs, and refreshes the HUD values every 1 sec.


didMoveMapTo

public void didMoveMapTo(int x,
                         int y)

This method is called when the map is moved.

(i.e. when the user scrolls the map).

Updates the viewport position on the minimap after the map has moved.


didMoveViewportTo

public void didMoveViewportTo(int x,
                              int y)

This method is called when the minimap viewport has been moved.

(i.e. minimap has been clicked on)


getInstance

public static City getInstance()
Returns an instance of City.

Returns:
An instance of City.

hideOverlay

public void hideOverlay()
Hides the overlay.


hint

public Hint hint()
Returns the active Hint.

Returns:
The active Hint.

menuBar

public MenuBar menuBar()
Returns an instance of MenuBar.

Returns:
An instance of MenuBar.

removeHint

public void removeHint()
Removes the active hint from view.


score

public int score()
Returns the city's current score.

Returns:
The city's current score (0 - 100%).

setHint

public void setHint(Hint hint)
Sets the active hint. This reference to it will be used later to remove it from view.

Parameters:
hint - The hint to be made active.

setScore

public void setScore(int value)
Sets the city's score. The score must be between 0 - 100.

Parameters:
An - integer with the new score.

showOverlay

public void showOverlay()
Shows an overlay to fade out the screen.


started

public void started()
Overrides started() in World from the Greenfoot framework. This is called when the game is started.

Overrides:
started in class greenfoot.World

stopped

public void stopped()
Overrides stopped() in World from the Greenfoot framework. This is called when the game is stopped.

Overrides:
stopped in class greenfoot.World