Package com.entities

Class Firestation


  • public class Firestation
    extends SimpleSprite
    The Firestation implementation, a static sprite in the game.
    Since:
    17/12/2019
    • Constructor Summary

      Constructors 
      Constructor Description
      Firestation​(com.badlogic.gdx.graphics.Texture texture, com.badlogic.gdx.graphics.Texture destroyedTexture, float xPos, float yPos, GameScreen gameScreen)
      Overloaded constructor containing all possible parameters.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void changeFiretruck​(int index)
      Swap active fire truck with indexed parked fire truck
      void checkRepairRefill​(int time, boolean includeActive)
      Repairs/Refills the fire truck if: - it is within 3 minutes - in the main carpark (fire station) - less than 100 health or water
      void drawDebug​(com.badlogic.gdx.graphics.glutils.ShapeRenderer renderer)
      Overloaded method for drawing debug information.
      Firetruck getActiveFireTruck()  
      Firetruck getFiretruckByType​(Constants.TruckType type)
      Gets a firetruck from the parked firetrucks given it's type.
      java.util.ArrayList<Firetruck> getParkedFireTrucks()  
      boolean hasParkedFiretrucks()
      Whether the fire station has any more active fire trucks
      boolean isDestroyed()  
      boolean isMenuOpen()  
      boolean isVulnerable()  
      void parkFireTruck​(Firetruck firetruck)
      Add fire truck to parked fire truck list
      void repairRefill​(Firetruck firetruck)
      Repair a firetruck over time.
      void setActiveFireTruck​(Firetruck fireTruck)  
      void toggleMenu​(boolean isOpen)
      Open or close the car park menu
      void update​(com.badlogic.gdx.graphics.g2d.Batch batch)
      Updates the firestation so that it is drawn every frame.
      void updateActiveArrow​(com.badlogic.gdx.graphics.glutils.ShapeRenderer shapeRenderer, java.util.ArrayList<ETFortress> fortresses)
      Updates the arrow that points to the nearest fortress
      void updateFiretruck​(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.graphics.glutils.ShapeRenderer shapeRenderer, com.badlogic.gdx.graphics.OrthographicCamera camera)
      Updates the active fire truck, check if the fire truck's health is 0 or below, if so "destroy" it
      • Methods inherited from class com.badlogic.gdx.graphics.g2d.Sprite

        draw, draw, flip, getBoundingRectangle, getColor, getOriginX, getOriginY, getRotation, getScaleX, getScaleY, getVertices, getX, getY, rotate90, scale, scroll, set, setAlpha, setBounds, setCenter, setCenterX, setCenterY, setColor, setColor, setFlip, setOrigin, setOriginBasedPosition, setOriginCenter, setPackedColor, setPosition, setRegion, setRotation, setScale, setScale, setU, setU2, setV, setV2, setX, setY, translate, translateX, translateY
      • Methods inherited from class com.badlogic.gdx.graphics.g2d.TextureRegion

        getRegionHeight, getRegionWidth, getRegionX, getRegionY, getTexture, getU, getU2, getV, getV2, isFlipX, isFlipY, setRegion, setRegion, setRegion, setRegion, setRegionHeight, setRegionWidth, setRegionX, setRegionY, setTexture, split, split
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Firestation

        public Firestation​(com.badlogic.gdx.graphics.Texture texture,
                           com.badlogic.gdx.graphics.Texture destroyedTexture,
                           float xPos,
                           float yPos,
                           GameScreen gameScreen)
        Overloaded constructor containing all possible parameters. Drawn with the given texture at the given position.
        Parameters:
        texture - The texture used to draw the Firestation with.
        destroyedTexture - The destoryed texture when Firestation is destroyed.
        xPos - The x-coordinate for the Firestation.
        yPos - The y-coordinate for the Firestation.
        gameScreen - GameScreen to be able to send popup messages to
    • Method Detail

      • update

        public void update​(com.badlogic.gdx.graphics.g2d.Batch batch)
        Updates the firestation so that it is drawn every frame. Also reduces the time before next repair can occur.
        Overrides:
        update in class SimpleSprite
        Parameters:
        batch - The batch to draw onto.
      • repairRefill

        public void repairRefill​(Firetruck firetruck)
        Repair a firetruck over time.
        Parameters:
        firetruck - The firetruck that will be repaired.
      • drawDebug

        public void drawDebug​(com.badlogic.gdx.graphics.glutils.ShapeRenderer renderer)
        Overloaded method for drawing debug information. Draws the hitbox as well as the range circle.
        Overrides:
        drawDebug in class SimpleSprite
        Parameters:
        renderer - The renderer used to draw the hitbox and range indicator with.
      • updateFiretruck

        public void updateFiretruck​(com.badlogic.gdx.graphics.g2d.Batch batch,
                                    com.badlogic.gdx.graphics.glutils.ShapeRenderer shapeRenderer,
                                    com.badlogic.gdx.graphics.OrthographicCamera camera)
        Updates the active fire truck, check if the fire truck's health is 0 or below, if so "destroy" it
        Parameters:
        batch - to draw textures
        shapeRenderer - to draw health and debug
        camera - eventually to control active firetruck hose
      • updateActiveArrow

        public void updateActiveArrow​(com.badlogic.gdx.graphics.glutils.ShapeRenderer shapeRenderer,
                                      java.util.ArrayList<ETFortress> fortresses)
        Updates the arrow that points to the nearest fortress
        Parameters:
        shapeRenderer - to draw the arrow polygon
        fortresses - to find nearest fortress
      • hasParkedFiretrucks

        public boolean hasParkedFiretrucks()
        Whether the fire station has any more active fire trucks
        Returns:
        true if there is a parked fire truck false otherwise
      • parkFireTruck

        public void parkFireTruck​(Firetruck firetruck)
        Add fire truck to parked fire truck list
        Parameters:
        firetruck - to park
      • checkRepairRefill

        public void checkRepairRefill​(int time,
                                      boolean includeActive)
        Repairs/Refills the fire truck if: - it is within 3 minutes - in the main carpark (fire station) - less than 100 health or water
        Parameters:
        time - used to check whether the station has been destroyed yet
        includeActive - true if car park menu if open, repair active fire truck and can see health/water increasing fasle menu is closed
      • toggleMenu

        public void toggleMenu​(boolean isOpen)
        Open or close the car park menu
        Parameters:
        isOpen - true if menu is just being opened false menu is being closed
      • changeFiretruck

        public void changeFiretruck​(int index)
        Swap active fire truck with indexed parked fire truck
        Parameters:
        index - of parked fire truck
      • getFiretruckByType

        public Firetruck getFiretruckByType​(Constants.TruckType type)
        Gets a firetruck from the parked firetrucks given it's type. Also removes it from the parked firetrucks
        Parameters:
        type - The type of truck to return
        Returns:
        The firetruck of the given type
      • setActiveFireTruck

        public void setActiveFireTruck​(Firetruck fireTruck)
      • getActiveFireTruck

        public Firetruck getActiveFireTruck()
      • getParkedFireTrucks

        public java.util.ArrayList<Firetruck> getParkedFireTrucks()
      • isMenuOpen

        public boolean isMenuOpen()
      • isVulnerable

        public boolean isVulnerable()
      • isDestroyed

        public boolean isDestroyed()