Class PlayerSkillComponent
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.components.player.PlayerSkillComponent
Skill component for managing player skills and the player state as a result of those skills.
Designed to be a subcomponent of the PlayerActions.java class as a controller of
the skill subset of the player's actions.
Functions in the class should be called from the player actions class, passing information from
the player action manager into this class's skill functionality.
-
Nested Class Summary
Nested Classes -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionPlayerSkillComponent
(Entity playerEntity) Initialises the player skill component, taking a player entity as the parent component. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSkillPoints
(int skillPoints) void
Damages all enemies around player and knocks them back.boolean
Checks if the player is in the bleed skill statevoid
Ensures enemy is not a projectile then sets entity enemy variablevoid
Speeds up player movement for charge attackvoid
checkBleed
(Entity target) Does damage over time to target.boolean
checkSkillEnd
(PlayerSkillComponent.SkillTypes skillName) Checks for the end of a skill, should be polled continuously in update.boolean
cooldownFinished
(String skill, long cooldown) Checks if the cooldown period is over for the given skill and updates cooldown map.com.badlogic.gdx.math.Vector2
getModifiedMovement
(com.badlogic.gdx.math.Vector2 baseMovement) Returns the modified movement vector based on base movement speed and the alterations of the skill state on the player movement.int
void
Apply bleed effect to enemyvoid
Apply root effect to enemyboolean
Checks if the enemy has bleeding appliedboolean
Checks if the player is in the block skill stateboolean
Checks if the player is in the charge skill stateboolean
Checks if the player is in the charge up skill stateboolean
Checks if the player is in the dash skill stateboolean
Checks if the player is in the dodge skill stateboolean
Checks the skill state for invulnerability as a result of a player skill.boolean
isRooted()
Checks if the enemy has rooted appliedboolean
Checks if the player is in the teleport skill stateboolean
Checks if the movement of the player entity should be altered based on skill state.void
resetSkills
(Entity entity) Resets all skills for the skill event of player entityboolean
Checks if the player is in the root skill statevoid
setSkill
(int skillNum, PlayerSkillComponent.SkillTypes skillName, Entity entity, PlayerActions playerActionsComponent) Sets a listener to the skill eventvoid
setSkillAnimator
(Entity skillAnimator) Sets the skill animator entity for this skill component, so this skill component can interact with the corresponding animator.void
setSkillCooldown
(String skill) Sets an existing skill cooldown to a new cooldown.boolean
Functional equivalent of isInvulnerable but also triggers effects internally based on skill states.void
The functional start of the bleed skill.void
The functional start of the block skill.void
The functional start of the charge.void
startDash
(com.badlogic.gdx.math.Vector2 moveDirection) The functional start of the dash.void
startDodge
(com.badlogic.gdx.math.Vector2 moveDirection) The functional start of the dodge skill.void
The functional start of the fireball ultimate skill.void
The functional start of the invulnerability skill.void
The functional start of the wrench projectile skill.void
The functional start of the root skill.void
The functional start of the teleport skill.void
The functional start of the timestop ultimate skill.void
Teleports the player a set distance from their current position in the walk direction.void
update()
Update should update the cooldowns/state of skills within the skill managerMethods inherited from class com.deco2800.game.components.Component
create, dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Constructor Details
-
PlayerSkillComponent
Initialises the player skill component, taking a player entity as the parent component.- Parameters:
playerEntity
- the player entity this skill component is a subcomponent of
-
-
Method Details
-
setSkillAnimator
Sets the skill animator entity for this skill component, so this skill component can interact with the corresponding animator. This entity should have as components at least a PlayerSkillAnimationController and an AnimationRenderComponent.- Parameters:
skillAnimator
- skill animator entity with PlayerSkillAnimationController and an AnimationRenderComponent
-
update
public void update()Update should update the cooldowns/state of skills within the skill manager -
addSkillPoints
public void addSkillPoints(int skillPoints) -
getSkillPoints
public int getSkillPoints() -
setSkill
public void setSkill(int skillNum, PlayerSkillComponent.SkillTypes skillName, Entity entity, PlayerActions playerActionsComponent) Sets a listener to the skill event- Parameters:
skillName
- the skill name: - "teleport" - the teleport skillskillNum
- the skill number (not 0 based and up to 2 skills)entity
- the player entity of the player actions componentplayerActionsComponent
- the player actions component containing the call for the skill to pass information into the skill manager
-
resetSkills
Resets all skills for the skill event of player entity- Parameters:
entity
- the player entity to remove all skill listeners from
-
movementIsModified
public boolean movementIsModified()Checks if the movement of the player entity should be altered based on skill state.- Returns:
- true - if the movement of the player should be modified based on skill state
-
getModifiedMovement
public com.badlogic.gdx.math.Vector2 getModifiedMovement(com.badlogic.gdx.math.Vector2 baseMovement) Returns the modified movement vector based on base movement speed and the alterations of the skill state on the player movement.- Parameters:
baseMovement
- the base player movement speed vector- Returns:
- the modified vector considering skill state alterations
-
isInvulnerable
public boolean isInvulnerable()Checks the skill state for invulnerability as a result of a player skill.- Returns:
- true if the player should be invulnerable false if the player should be able to take damage
-
skillDamageTrigger
public boolean skillDamageTrigger()Functional equivalent of isInvulnerable but also triggers effects internally based on skill states. Should be used instead of isInvulnerable unless just checking invulnerable state.- Returns:
- true if the player should be invulnerable false if the player should be able to take damage
-
checkSkillEnd
Checks for the end of a skill, should be polled continuously in update. Note: if not polled continuously cannot guarantee correct behaviour.- Parameters:
skillName
- - the name of the skill to check end condition- Returns:
- true if the skill has ended and the flag has not been polled false if the skill end has been read
-
isDashing
public boolean isDashing()Checks if the player is in the dash skill state- Returns:
- true - if the player is dashing false - otherwise
-
isCharging
public boolean isCharging()Checks if the player is in the charge skill state- Returns:
- true - if the player is charging false - otherwise
-
isChargingUp
public boolean isChargingUp()Checks if the player is in the charge up skill state- Returns:
- true - if the player is charging up false - otherwise
-
isTeleporting
public boolean isTeleporting()Checks if the player is in the teleport skill state- Returns:
- true - if the player is charging a teleport false - otherwise
-
isDodging
public boolean isDodging()Checks if the player is in the dodge skill state- Returns:
- true - if the player is dodging false - otherwise
-
isBlocking
public boolean isBlocking()Checks if the player is in the block skill state- Returns:
- true - if the player is blocking false - otherwise
-
bleedActive
public boolean bleedActive()Checks if the player is in the bleed skill state- Returns:
- true - if the player has bleed active false - otherwise
-
isBleeding
public boolean isBleeding()Checks if the enemy has bleeding applied- Returns:
- true - if the enemy is bleeding false - otherwise
-
rootActive
public boolean rootActive()Checks if the player is in the root skill state- Returns:
- true - if the player has root active false - otherwise
-
isRooted
public boolean isRooted()Checks if the enemy has rooted applied- Returns:
- true - if the enemy is rooted false - otherwise
-
startInvulnerabilitySkill
public void startInvulnerabilitySkill()The functional start of the invulnerability skill. Should be called when the player actions component registers invulnerability skill -
startDash
public void startDash(com.badlogic.gdx.math.Vector2 moveDirection) The functional start of the dash. Should be called when player actions component registers dash event.- Parameters:
moveDirection
- the direction of the players movement at the start of the dash event.
-
startTeleport
public void startTeleport()The functional start of the teleport skill. Should be called when player actions component registers teleport event. -
startDodge
public void startDodge(com.badlogic.gdx.math.Vector2 moveDirection) The functional start of the dodge skill. Should be called when player actions component registers dodge event. -
startBlock
public void startBlock()The functional start of the block skill. Should be called when player actions component registers block event. -
startRoot
public void startRoot()The functional start of the root skill. Should be called when player actions component registers root event. -
startUltimate
public void startUltimate()The functional start of the timestop ultimate skill. Should be called when player actions component registers ultimate event. -
startProjectileSkill
public void startProjectileSkill()The functional start of the wrench projectile skill. Should be called when player actions component registers projectile skill event. -
startFireballUltimate
public void startFireballUltimate()The functional start of the fireball ultimate skill. Should be called when player actions component registers ultimate event. -
hitRoot
Apply root effect to enemy- Parameters:
target
- enemy to apply effect on
-
startBleed
public void startBleed()The functional start of the bleed skill. Should be called when player actions component registers bleed event. -
hitBleed
Apply bleed effect to enemy- Parameters:
target
- enemy to apply effect on
-
checkBleed
Does damage over time to target.- Parameters:
target
- enemy to damage
-
teleportPlayer
public void teleportPlayer()Teleports the player a set distance from their current position in the walk direction. -
cooldownFinished
Checks if the cooldown period is over for the given skill and updates cooldown map.- Parameters:
skill
- the skill to checkcooldown
- the cooldown period (in milliseconds)- Returns:
- true if cooldown period is over, false otherwise
-
setSkillCooldown
Sets an existing skill cooldown to a new cooldown.- Parameters:
skill
- the skill to check
-
startCharge
public void startCharge()The functional start of the charge. Should be called when player actions component registers charge event. -
chargeMove
public void chargeMove()Speeds up player movement for charge attack -
chargeHit
Ensures enemy is not a projectile then sets entity enemy variable- Parameters:
target
- the first enemy the player collides with
-
aoeAttack
public void aoeAttack()Damages all enemies around player and knocks them back.
-