Class PlayerTouchAttackComponent
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.components.TouchAttackComponent
com.deco2800.game.components.player.PlayerTouchAttackComponent
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionPlayerTouchAttackComponent
(short targetLayer) Create a component which attacks enemy entities on collision, without knockback. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Method triggered when the player is holding a ranged weapon, which creates the projectiles on the mapvoid
Method which sets the base cooldown to 4 seconds when attack with a fistvoid
attackWithPhysicalWeapon
(Entity weaponEquipped, Entity auraEquipped) Method to set attack cooldown and trigger attack animation dependent on the weapon and aura equippedvoid
Method called to check if the player can attackvoid
create()
Called when the entity is created and registered.Returns the combat item animatorvoid
playAttackAnimation
(Entity weaponEquipped, Entity auraEquipped) Plays attack animation dependent on weapon in handvoid
playAttackSounds
(Entity weaponEquipped) Plays attack sounds for combat weapons dependent on the weapon in handvoid
setCombatAnimator
(Entity combatAnimator) Sets the combat item animator for this actions componentvoid
update()
Called once per frame of the game, and should be used for most component logic.Methods inherited from class com.deco2800.game.components.Component
dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Constructor Details
-
PlayerTouchAttackComponent
public PlayerTouchAttackComponent(short targetLayer) Create a component which attacks enemy entities on collision, without knockback.- Parameters:
targetLayer
- The physics layer of the target's collider.
-
-
Method Details
-
create
public void create()Description copied from class:Component
Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished.- Overrides:
create
in classTouchAttackComponent
-
update
public void update()Description copied from class:Component
Called once per frame of the game, and should be used for most component logic. Not called if component is disabled. -
setCombatAnimator
Sets the combat item animator for this actions component- Parameters:
combatAnimator
- the combat animator entity which has subcomponents PlayerSkillAnimationController and AnimationRenderer
-
getCombatAnimator
Returns the combat item animator- Returns:
- combat item animator
-
checkCanAttack
public void checkCanAttack()Method called to check if the player can attack -
playAttackSounds
Plays attack sounds for combat weapons dependent on the weapon in hand- Parameters:
weaponEquipped
- The entity representing the weapon the player is currently holding
-
playAttackAnimation
Plays attack animation dependent on weapon in hand- Parameters:
weaponEquipped
- The entity representing the weapon the player is currently holdingauraEquipped
- The entity representing the aura that is currently active
-
attackWithPhysicalWeapon
Method to set attack cooldown and trigger attack animation dependent on the weapon and aura equipped- Parameters:
weaponEquipped
- The entity representing the weapon the player is currently holdingauraEquipped
- The entity representing the aura that is currently active
-
attackWithNoWeapon
public void attackWithNoWeapon()Method which sets the base cooldown to 4 seconds when attack with a fist -
attackRanged
public void attackRanged()Method triggered when the player is holding a ranged weapon, which creates the projectiles on the map
-