Package com.mygdx.game.Entitys
Class NPCShip
- java.lang.Object
-
- com.mygdx.game.Entitys.Entity
-
- com.mygdx.game.Entitys.Ship
-
- com.mygdx.game.Entitys.NPCShip
-
- All Implemented Interfaces:
CollisionCallBack
public class NPCShip extends Ship implements CollisionCallBack
NPC ship entity class.
-
-
Field Summary
Fields Modifier and Type Field Description com.badlogic.gdx.ai.fsm.StateMachine<NPCShip,EnemyState>stateMachine-
Fields inherited from class com.mygdx.game.Entitys.Ship
shipDirections
-
-
Constructor Summary
Constructors Constructor Description NPCShip()Creates an initial state machine Changed for Assessment 2: - Added lastShootTime to store the time when the ship last attacked
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattackShip(Ship ship)Added for Assessment 2, shoots a cannonball towards the player shipvoidcircleOrigin()Added for Assessment 2 Creates a new steering behaviour that will make the NPC circle the college it is attached to (doesn't factor in obstacles)com.badlogic.gdx.math.Vector2directionToShip(Ship ship)Added for Assessment 2, calculates the direction an Enemy Ship is invoidEnterTrigger(CollisionInfo info)if the aggro fixture hit a ship set it as the targetvoidExitTrigger(CollisionInfo info)if a target has left remove it from the potential targets QueuevoidfollowTarget()creates a new steering behaviour that will make the NPC beeline for the target (doesn't factor in obstacles)EnemyStategetCurrentState()voidstopMovement()stops all movement and sets the behaviour to nullvoidupdate()Amended for Assessment 2: Added check for life and kills stateMachine and ship in case of death updates the state machine-
Methods inherited from class com.mygdx.game.Entitys.Ship
BeginContact, EndContact, getAttackRange, getFaction, getHealth, getPlunder, getPoints, getPosition, getValue, isAlive, plunder, points, resetToDefault, setFaction, setShipDirection, setShipDirection, shoot, shoot
-
Methods inherited from class com.mygdx.game.Entitys.Entity
addComponent, addComponents, cleanUp, dispose, getComponent, getComponent, getName, raiseEvents, setName
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.mygdx.game.Physics.CollisionCallBack
BeginContact, EndContact
-
-
-
-
Field Detail
-
stateMachine
public com.badlogic.gdx.ai.fsm.StateMachine<NPCShip,EnemyState> stateMachine
-
-
Method Detail
-
update
public void update()
Amended for Assessment 2: Added check for life and kills stateMachine and ship in case of death updates the state machine
-
followTarget
public void followTarget()
creates a new steering behaviour that will make the NPC beeline for the target (doesn't factor in obstacles)
-
circleOrigin
public void circleOrigin()
Added for Assessment 2 Creates a new steering behaviour that will make the NPC circle the college it is attached to (doesn't factor in obstacles)
-
stopMovement
public void stopMovement()
stops all movement and sets the behaviour to null
-
directionToShip
public com.badlogic.gdx.math.Vector2 directionToShip(Ship ship)
Added for Assessment 2, calculates the direction an Enemy Ship is in
-
attackShip
public void attackShip(Ship ship)
Added for Assessment 2, shoots a cannonball towards the player ship
-
getCurrentState
public EnemyState getCurrentState()
- Returns:
- the current state the NPCShip is in
-
EnterTrigger
public void EnterTrigger(CollisionInfo info)
if the aggro fixture hit a ship set it as the target- Specified by:
EnterTriggerin interfaceCollisionCallBack- Overrides:
EnterTriggerin classShip- Parameters:
info- the collision info
-
ExitTrigger
public void ExitTrigger(CollisionInfo info)
if a target has left remove it from the potential targets Queue- Specified by:
ExitTriggerin interfaceCollisionCallBack- Overrides:
ExitTriggerin classShip- Parameters:
info- collision info
-
-