Package com.entities

Class Patrol


  • public class Patrol
    extends PatrolMovementSprite
    This class is used to create a patrol. A patrol can detect and attack a firetruck if a firetruck is within it's range. It can also be attacked by a firetruck. It extends PatrolMovementSprite which determines how the patrol moves around the map
    • Constructor Summary

      Constructors 
      Constructor Description
      Patrol​(java.util.ArrayList<com.badlogic.gdx.graphics.Texture> textureSlices, MapGraph mapGraph)
      The constructor for Patrol
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canShootProjectile()
      Returns if a patrol can shoot a projectile
      void drawDebug​(com.badlogic.gdx.graphics.glutils.ShapeRenderer renderer)
      Enables drawing of the hitbox to it can be seen.
      boolean isDead()  
      boolean isInRadius​(com.badlogic.gdx.math.Vector2 position)
      Simple method for detecting whether a vector, fire truck, is within attacking distance of that fortress' range
      void removeDead​(MapGraph mapGraph)
      If a patrol has died have to remove the road the patrol locked when it died from lockedRoads in mapGraph Otherwise no patrols will be able to travel on that road
      void update​(com.badlogic.gdx.graphics.g2d.Batch batch)
      Called from gameScreen, first checks whether the patrol has been killed, it draws the patrol calls super to update the patrols movement and updates its detection range so that it moves with the movement of the patrol.
      void updateMovement()
      Just updates the movement of the patrol, doesn't draw the sprite or check detection range
      • Methods inherited from class com.badlogic.gdx.graphics.g2d.Sprite

        draw, draw, flip, getBoundingRectangle, getColor, getOriginX, getOriginY, getRotation, getScaleX, getScaleY, getVertices, 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

      • Patrol

        public Patrol​(java.util.ArrayList<com.badlogic.gdx.graphics.Texture> textureSlices,
                      MapGraph mapGraph)
        The constructor for Patrol
        Parameters:
        textureSlices - List of textures that are layered on top of each other to draw the patrol
        mapGraph - Graph of junctions - used by PatrolMovementSprite to determine the patrol's movement
    • Method Detail

      • update

        public void update​(com.badlogic.gdx.graphics.g2d.Batch batch)
        Called from gameScreen, first checks whether the patrol has been killed, it draws the patrol calls super to update the patrols movement and updates its detection range so that it moves with the movement of the patrol.
        Overrides:
        update in class PatrolMovementSprite
        Parameters:
        batch - The batch to draw onto.
      • updateMovement

        public void updateMovement()
        Just updates the movement of the patrol, doesn't draw the sprite or check detection range
      • isInRadius

        public boolean isInRadius​(com.badlogic.gdx.math.Vector2 position)
        Simple method for detecting whether a vector, fire truck, is within attacking distance of that fortress' range
        Parameters:
        position - vector to check
        Returns:
        true position is within range false otherwise
      • canShootProjectile

        public boolean canShootProjectile()
        Returns if a patrol can shoot a projectile
        Returns:
        true if 30ms has passed since the patrol last fired a projectile false if less than 30ms has passed since the patrol last fired a projectile
      • removeDead

        public void removeDead​(MapGraph mapGraph)
        If a patrol has died have to remove the road the patrol locked when it died from lockedRoads in mapGraph Otherwise no patrols will be able to travel on that road
        Parameters:
        mapGraph - Graph of junctions - used by PatrolMovementSprite * to determine the patrol's movement
      • drawDebug

        public void drawDebug​(com.badlogic.gdx.graphics.glutils.ShapeRenderer renderer)
        Description copied from class: SimpleSprite
        Enables drawing of the hitbox to it can be seen.
        Overrides:
        drawDebug in class SimpleSprite
        Parameters:
        renderer - The shape renderer to draw onto.
      • isDead

        public boolean isDead()