Package com.entities
Class Patrol
- java.lang.Object
-
- com.badlogic.gdx.graphics.g2d.TextureRegion
-
- com.badlogic.gdx.graphics.g2d.Sprite
-
- com.sprites.SimpleSprite
-
- com.sprites.PatrolMovementSprite
-
- com.entities.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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanShootProjectile()Returns if a patrol can shoot a projectilevoiddrawDebug(com.badlogic.gdx.graphics.glutils.ShapeRenderer renderer)Enables drawing of the hitbox to it can be seen.booleanisDead()booleanisInRadius(com.badlogic.gdx.math.Vector2 position)Simple method for detecting whether a vector, fire truck, is within attacking distance of that fortress' rangevoidremoveDead(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 roadvoidupdate(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.voidupdateMovement()Just updates the movement of the patrol, doesn't draw the sprite or check detection range-
Methods inherited from class com.sprites.PatrolMovementSprite
getGoal, getThis, getX, getY, setGoal, step
-
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, 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
-
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 patrolmapGraph- 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:
updatein classPatrolMovementSprite- 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:
trueposition is within rangefalseotherwise
-
canShootProjectile
public boolean canShootProjectile()
Returns if a patrol can shoot a projectile- Returns:
trueif 30ms has passed since the patrol last fired a projectilefalseif 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:SimpleSpriteEnables drawing of the hitbox to it can be seen.- Overrides:
drawDebugin classSimpleSprite- Parameters:
renderer- The shape renderer to draw onto.
-
isDead
public boolean isDead()
-
-