Package pvzclone.controller.impl
Class ControllerImpl
java.lang.Object
pvzclone.controller.impl.ControllerImpl
- All Implemented Interfaces:
Controller
Class that implements the Controller.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalls the main loop of the game.voidchooseLevel(int numberOfTheLevel) Sets the number of the Level to the number of the argument passed.Retrieves the number of the chosen level if the level was chosen, if not it returns an empty Optional.Retrieves the set of entities in the game.intReturns the number of levels available in the application.intRetrieves the points from the GameState.voidIncreases the points obtained by the suns in GameState.voidthis method communicates with the model telling him the position of the new plant.
-
Constructor Details
-
ControllerImpl
public ControllerImpl()Initializes the game.
-
-
Method Details
-
callMainloop
public void callMainloop()Description copied from interface:ControllerCalls the main loop of the game. This method should be called after the game is initialized.- Specified by:
callMainloopin interfaceController
-
getEntities
Description copied from interface:ControllerRetrieves the set of entities in the game. Entities represent the elements present in the game world.- Specified by:
getEntitiesin interfaceController- Returns:
- a Set of Entities representing the elements in the game world.
-
newPlant
Description copied from interface:Controllerthis method communicates with the model telling him the position of the new plant.- Specified by:
newPlantin interfaceController- Parameters:
pos- is the position of the new plant.
-
increaseSunPoints
public void increaseSunPoints()Description copied from interface:ControllerIncreases the points obtained by the suns in GameState.- Specified by:
increaseSunPointsin interfaceController
-
getSunScore
public int getSunScore()Description copied from interface:ControllerRetrieves the points from the GameState.- Specified by:
getSunScorein interfaceController- Returns:
- points obtained at the moment.
-
chooseLevel
public void chooseLevel(int numberOfTheLevel) Description copied from interface:ControllerSets the number of the Level to the number of the argument passed.- Specified by:
chooseLevelin interfaceController- Parameters:
numberOfTheLevel- level index.
-
getChosenLevel
Description copied from interface:ControllerRetrieves the number of the chosen level if the level was chosen, if not it returns an empty Optional.- Specified by:
getChosenLevelin interfaceController- Returns:
- number of the level that we chose.
-
getLevelCount
public int getLevelCount()Description copied from interface:ControllerReturns the number of levels available in the application.- Specified by:
getLevelCountin interfaceController- Returns:
- number of levels available in the application.
-