Package com.entities
Class Firestation
- java.lang.Object
-
- com.badlogic.gdx.graphics.g2d.TextureRegion
-
- com.badlogic.gdx.graphics.g2d.Sprite
-
- com.sprites.SimpleSprite
-
- com.entities.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 voidchangeFiretruck(int index)Swap active fire truck with indexed parked fire truckvoidcheckRepairRefill(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 watervoiddrawDebug(com.badlogic.gdx.graphics.glutils.ShapeRenderer renderer)Overloaded method for drawing debug information.FiretruckgetActiveFireTruck()FiretruckgetFiretruckByType(Constants.TruckType type)Gets a firetruck from the parked firetrucks given it's type.java.util.ArrayList<Firetruck>getParkedFireTrucks()booleanhasParkedFiretrucks()Whether the fire station has any more active fire trucksbooleanisDestroyed()booleanisMenuOpen()booleanisVulnerable()voidparkFireTruck(Firetruck firetruck)Add fire truck to parked fire truck listvoidrepairRefill(Firetruck firetruck)Repair a firetruck over time.voidsetActiveFireTruck(Firetruck fireTruck)voidtoggleMenu(boolean isOpen)Open or close the car park menuvoidupdate(com.badlogic.gdx.graphics.g2d.Batch batch)Updates the firestation so that it is drawn every frame.voidupdateActiveArrow(com.badlogic.gdx.graphics.glutils.ShapeRenderer shapeRenderer, java.util.ArrayList<ETFortress> fortresses)Updates the arrow that points to the nearest fortressvoidupdateFiretruck(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.sprites.SimpleSprite
decreaseInternalTime, dispose, getCentre, getCentreX, getCentreY, getDamageHitBox, getHealthBar, getHeight, getInternalTime, getMovementHitBox, getWidth, removeSprite, resetRotation, rotate, setInternalTime, setMovementHitBox, setSize
-
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
-
-
-
-
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:
updatein classSimpleSprite- 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:
drawDebugin classSimpleSprite- 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 texturesshapeRenderer- to draw health and debugcamera- 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 polygonfortresses- to find nearest fortress
-
hasParkedFiretrucks
public boolean hasParkedFiretrucks()
Whether the fire station has any more active fire trucks- Returns:
trueif there is a parked fire truckfalseotherwise
-
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 yetincludeActive-trueif car park menu if open, repair active fire truck and can see health/water increasingfaslemenu is closed
-
toggleMenu
public void toggleMenu(boolean isOpen)
Open or close the car park menu- Parameters:
isOpen-trueif menu is just being openedfalsemenu 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()
-
-