Package pvzclone.controller.impl
Class ControllerImpl
java.lang.Object
pvzclone.controller.impl.ControllerImpl
- All Implemented Interfaces:
Controller
Class that implements the Controller.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Calls the main loop of the game.void
chooseLevel
(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.int
Returns the number of levels available in the application.int
Retrieves the points from the GameState.void
Increases the points obtained by the suns in GameState.void
this 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:Controller
Calls the main loop of the game. This method should be called after the game is initialized.- Specified by:
callMainloop
in interfaceController
-
getEntities
Description copied from interface:Controller
Retrieves the set of entities in the game. Entities represent the elements present in the game world.- Specified by:
getEntities
in interfaceController
- Returns:
- a Set of Entities representing the elements in the game world.
-
newPlant
Description copied from interface:Controller
this method communicates with the model telling him the position of the new plant.- Specified by:
newPlant
in interfaceController
- Parameters:
pos
- is the position of the new plant.
-
increaseSunPoints
public void increaseSunPoints()Description copied from interface:Controller
Increases the points obtained by the suns in GameState.- Specified by:
increaseSunPoints
in interfaceController
-
getSunScore
public int getSunScore()Description copied from interface:Controller
Retrieves the points from the GameState.- Specified by:
getSunScore
in interfaceController
- Returns:
- points obtained at the moment.
-
chooseLevel
public void chooseLevel(int numberOfTheLevel) Description copied from interface:Controller
Sets the number of the Level to the number of the argument passed.- Specified by:
chooseLevel
in interfaceController
- Parameters:
numberOfTheLevel
- level index.
-
getChosenLevel
Description copied from interface:Controller
Retrieves the number of the chosen level if the level was chosen, if not it returns an empty Optional.- Specified by:
getChosenLevel
in interfaceController
- Returns:
- number of the level that we chose.
-
getLevelCount
public int getLevelCount()Description copied from interface:Controller
Returns the number of levels available in the application.- Specified by:
getLevelCount
in interfaceController
- Returns:
- number of levels available in the application.
-