Package com.screens

Class GameScreen

  • All Implemented Interfaces:
    com.badlogic.gdx.Screen

    public class GameScreen
    extends java.lang.Object
    implements com.badlogic.gdx.Screen
    Display 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
      void cameraZoom​(float zoom)
      Sets the zoomTarget that the user sets with the scroll wheel
      void checkForCollisions()
      Checks to see if any collisions have occurred
      void checkIfCarpark()
      Checks to see if the fire truck is to be opened, if so change screen
      void checkIfGameOver()
      Checks to see if the player has won or lost the game.
      void constructFireTruck​(boolean isActive, Constants.TruckType type)
      Creates a fire truck
      void createPatrol()
      Spawns a patrol, up to a certain number
      void dispose()
      Dispose of main game assets upon completion.
      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
      Firetruck getActiveTruck()  
      int getDifficulty()
      Getter for the game screen difficulty
      int[] getETFortressesDestroyed()
      Returns a tuple containing the number of fortresses destroyed and total number of fortresses
      Firestation getFirestation()  
      int getFireStationTime()
      Returns the time for the fire station
      int getNumberOfMinigames()  
      SaveControls getSaveControls()
      Getter for the game screen save controls
      int getScore()  
      int getTime()  
      void hide()
      Actions to perform when the main game is hidden.
      boolean isInTutorial()
      Checks if the game is in the tutorial
      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.
      void removeMinigame​(MinigameSprite minigameSprite)
      Called after the minigame has been won.
      void render​(float delta)
      Render function to display all elements in the main game.
      void resize​(int width, int height)
      Resize the screen.
      void resume()
      ============================================================== Overridden for assessment 3 ============================================================== Actions to perform when the main game is resumed.
      void saveGame​(int saveNumber)
      Save the game into a given save file
      void setScore​(int score)  
      void show()
      Actions to perform on first render cycle of the game
      void showPopupText​(java.lang.String text, int repeat, int interval)
      Queues a popup message and resets the popup timer
      void updatePatrolMovements()
      Updates only the movement of the patrol when the player is in the car park screen
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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:
        show in interface com.badlogic.gdx.Screen
      • render

        public void render​(float delta)
        Render function to display all elements in the main game.
        Specified by:
        render in interface com.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:
        resize in interface com.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:
        hide in interface com.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:
        pause in interface com.badlogic.gdx.Screen
      • resume

        public void resume()
        ============================================================== Overridden for assessment 3 ============================================================== Actions to perform when the main game is resumed.
        Specified by:
        resume in interface com.badlogic.gdx.Screen
      • dispose

        public void dispose()
        Dispose of main game assets upon completion.
        Specified by:
        dispose in interface com.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 truck
        type - 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 display
        repeat - how many times the message should appear
        interval - 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 0 time if time less than 0 0
      • getTime

        public int getTime()
      • getScore

        public int getScore()
      • setScore

        public void setScore​(int score)
      • getNumberOfMinigames

        public int getNumberOfMinigames()
      • getActiveTruck

        public Firetruck getActiveTruck()