Package com.screens
Class GameScreen
- java.lang.Object
-
- com.screens.GameScreen
-
- All Implemented Interfaces:
com.badlogic.gdx.Screen
public class GameScreen extends java.lang.Object implements com.badlogic.gdx.ScreenDisplay the main game.- Since:
- 23/11/2019
-
-
Constructor Summary
Constructors Constructor Description GameScreen(Kroy game, boolean isTutorial)The constructor for the main game screen.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcameraZoom(float zoom)Sets the zoomTarget that the user sets with the scroll wheelvoidcheckForCollisions()Checks to see if any collisions have occurredvoidcheckIfCarpark()Checks to see if the fire truck is to be opened, if so change screenvoidcheckIfGameOver()Checks to see if the player has won or lost the game.voidconstructFireTruck(boolean isActive, Constants.TruckType type)Creates a fire truckvoidcreatePatrol()Spawns a patrol, up to a certain numbervoiddispose()Dispose of main game assets upon completion.voidfinishTutorial()Multiple statements to reset the game after the tutorial has terminated: - reset truck water + position - show good luck test - start fire station timer - reset zoom - reset patrols The shader will also change, and collisions will now begin to occur, starting the gameFiretruckgetActiveTruck()intgetDifficulty()Getter for the game screen difficultyint[]getETFortressesDestroyed()Returns a tuple containing the number of fortresses destroyed and total number of fortressesFirestationgetFirestation()intgetFireStationTime()Returns the time for the fire stationintgetNumberOfMinigames()SaveControlsgetSaveControls()Getter for the game screen save controlsintgetScore()intgetTime()voidhide()Actions to perform when the main game is hidden.booleanisInTutorial()Checks if the game is in the tutorialvoidpause()================================================== New function for assessment 3 =================================================== Pauses the game and changes the screen to PauseScreen Actions to perform when the main game is paused.voidremoveMinigame(MinigameSprite minigameSprite)Called after the minigame has been won.voidrender(float delta)Render function to display all elements in the main game.voidresize(int width, int height)Resize the screen.voidresume()============================================================== Overridden for assessment 3 ============================================================== Actions to perform when the main game is resumed.voidsaveGame(int saveNumber)Save the game into a given save filevoidsetScore(int score)voidshow()Actions to perform on first render cycle of the gamevoidshowPopupText(java.lang.String text, int repeat, int interval)Queues a popup message and resets the popup timervoidupdatePatrolMovements()Updates only the movement of the patrol when the player is in the car park screen
-
-
-
Constructor Detail
-
GameScreen
public GameScreen(Kroy game, boolean isTutorial)
The constructor for the main game screen. All main game logic is contained.- Parameters:
game- The game object.isTutorial- Whether the game should show the tutorial or not
-
-
Method Detail
-
show
public void show()
Actions to perform on first render cycle of the game- Specified by:
showin interfacecom.badlogic.gdx.Screen
-
render
public void render(float delta)
Render function to display all elements in the main game.- Specified by:
renderin interfacecom.badlogic.gdx.Screen- Parameters:
delta- The delta time of the game, updated every game second rather than frame.
-
resize
public void resize(int width, int height)Resize the screen.- Specified by:
resizein interfacecom.badlogic.gdx.Screen- Parameters:
width- The width of the screen.height- The height of the screen.
-
hide
public void hide()
Actions to perform when the main game is hidden.- Specified by:
hidein interfacecom.badlogic.gdx.Screen
-
pause
public void pause()
================================================== New function for assessment 3 =================================================== Pauses the game and changes the screen to PauseScreen Actions to perform when the main game is paused.- Specified by:
pausein interfacecom.badlogic.gdx.Screen
-
resume
public void resume()
============================================================== Overridden for assessment 3 ============================================================== Actions to perform when the main game is resumed.- Specified by:
resumein interfacecom.badlogic.gdx.Screen
-
dispose
public void dispose()
Dispose of main game assets upon completion.- Specified by:
disposein interfacecom.badlogic.gdx.Screen
-
createPatrol
public void createPatrol()
Spawns a patrol, up to a certain number
-
saveGame
public void saveGame(int saveNumber)
Save the game into a given save file- Parameters:
saveNumber- The number of the save file to store the game in
-
getSaveControls
public SaveControls getSaveControls()
Getter for the game screen save controls- Returns:
- The save controls object
-
getDifficulty
public int getDifficulty()
Getter for the game screen difficulty- Returns:
- The difficulty of the game
-
removeMinigame
public void removeMinigame(MinigameSprite minigameSprite)
Called after the minigame has been won. Removed the minigame from the main game- Parameters:
minigameSprite- the sprite to remove from the game
-
isInTutorial
public boolean isInTutorial()
Checks if the game is in the tutorial- Returns:
- Whether the game is in the tutorial (true) or not (false)
-
updatePatrolMovements
public void updatePatrolMovements()
Updates only the movement of the patrol when the player is in the car park screen
-
checkIfCarpark
public void checkIfCarpark()
Checks to see if the fire truck is to be opened, if so change screen
-
checkIfGameOver
public void checkIfGameOver()
Checks to see if the player has won or lost the game. Navigates back to the main menu if they won or lost.
-
checkForCollisions
public void checkForCollisions()
Checks to see if any collisions have occurred
-
cameraZoom
public void cameraZoom(float zoom)
Sets the zoomTarget that the user sets with the scroll wheel- Parameters:
zoom- positive for zoom out, negative for zoom in
-
constructFireTruck
public void constructFireTruck(boolean isActive, Constants.TruckType type)Creates a fire truck- Parameters:
isActive- whether this truck is the active, starting trucktype- the type of truck to spawn
-
showPopupText
public void showPopupText(java.lang.String text, int repeat, int interval)Queues a popup message and resets the popup timer- Parameters:
text- text to displayrepeat- how many times the message should appearinterval- how long the message should stay up for
-
getETFortressesDestroyed
public int[] getETFortressesDestroyed()
Returns a tuple containing the number of fortresses destroyed and total number of fortresses- Returns:
- tuple of ints
-
finishTutorial
public void finishTutorial()
Multiple statements to reset the game after the tutorial has terminated: - reset truck water + position - show good luck test - start fire station timer - reset zoom - reset patrols The shader will also change, and collisions will now begin to occur, starting the game
-
getFireStationTime
public int getFireStationTime()
Returns the time for the fire station- Returns:
if time greater than 0timeif time less than 00
-
getTime
public int getTime()
-
getScore
public int getScore()
-
setScore
public void setScore(int score)
-
getFirestation
public Firestation getFirestation()
-
getNumberOfMinigames
public int getNumberOfMinigames()
-
getActiveTruck
public Firetruck getActiveTruck()
-
-