![]() |
Eye of the Nile Docs
Everything you need to know to get started!
|
Handles all the attacks the player can perform, including both standard attacks and all ability attacks. This script contains multiple overloads of some functions to provide more functionality if desired.
Documentation updated 8/30/2024
Public Member Functions | |
void | Melee (string animName, float cooldown) |
Sets up the variables for TriggerMelee(), and then triggers the attack animation and cooldown. | |
void | Melee (string animName, float cooldown, float range, float kbStrength) |
Sets up the variables for TriggerMelee(), and then triggers the attack animation and cooldown. This overload provides two extra parameters to customize the range and knockback. | |
void | ShootProjectile (GameObject projectilePrefab) |
Spawn a projectile from the attack point and set it facing the correct direction. No cooldown overload. This will not start a cooldown and will ignore the current cooldown. | |
void | ShootProjectile (GameObject projectilePrefab, float cooldown) |
Spawn a projectile from the attack point and set it facing the correct direction. Then start the attack cooldown. | |
void | ShootProjectileBurst (GameObject projectilePrefab, int numProjectiles, float delay) |
Will start a coroutine for ProjectileBurst, which F\fires a projectile numProjectiles times, wtih delay seconds in between. | |
Private Member Functions | |
void | Awake () |
Set reference to the PlayerStatsHolder. | |
void | Update () |
Every frame, check if the user is pressing the melee key or projectile key. | |
void | MeleeTrigger () |
This function is triggered by the melee animation at the peak of the sword swing. At that moment, the actual melee attack happens. | |
IEnumerator | CooldownWait (float seconds) |
Prevents any attacks that observe the attack cooldown from triggering for the given amount of seconds. | |
IEnumerator | ProjectileBurst (GameObject projectilePrefab, int numProjectiles, float delay) |
Fires a projectile numProjectiles times, wtih delay seconds in between. | |
Private Attributes | |
PlayerStatHolder | playerStats |
Reference to the PlayerStatsHolder, which is responsible for managing the player's modifiable stats. | |
Transform | attackPoint |
Reference to the player's's attack point. It's a point in space that's a child of the player, existing some distance in front of it. Projectiles spawn from the attack point, and melee attacks scan for enemies to damage from a certain radius around it. | |
LayerMask | attackableLayers |
Objects on these layers which can be hit from the player's melee attacks. | |
Animator | animator |
Reference the the player's animator. | |
bool | onCooldown = false |
True if attacking is on cooldown, preventing another attack from being used. | |
Default Melee Attack | |
Information related to the player's default melee attack. | |
KeyCode | meleeKey = KeyCode.Mouse0 |
string | meleeAnimation = "Attack" |
Name of the animation to play. | |
float | curRange |
The melee range that will be used for the next attack. If no range parameter is given to Melee(), this will be set to meleeRange by default. | |
float | curKnockback |
The melee knockback that will be used for the next attack. If no range parameter is given to Melee(), this will be set to meleeKnockback by default. | |
Default Projectile Attack | |
Information related to the player's default projectile attack. | |
KeyCode | projectileKey = KeyCode.Mouse1 |
GameObject | defaultProjectilePrefab |
Reference to the projectile this attack will instantiate. | |
float | ProjCooldown = 1f |
Cooldown time for all attacks must wait after the projectile attack is used. | |
|
private |
Set reference to the PlayerStatsHolder.
|
private |
Prevents any attacks that observe the attack cooldown from triggering for the given amount of seconds.
seconds | How long the cooldown should last, in seconds. |
void PlayerAttackManager.Melee | ( | string | animName, |
float | cooldown ) |
Sets up the variables for TriggerMelee(), and then triggers the attack animation and cooldown.
animName | Name of the attack animation. |
cooldown | Length of the attack cooldown after this ability is triggered. |
void PlayerAttackManager.Melee | ( | string | animName, |
float | cooldown, | ||
float | range, | ||
float | kbStrength ) |
Sets up the variables for TriggerMelee(), and then triggers the attack animation and cooldown. This overload provides two extra parameters to customize the range and knockback.
animName | Name of the attack animation. |
cooldown | Length of the attack cooldown after this ability is triggered. |
range | The distance from the attack point that enemies will be hit by the melee attack (size of attack point). |
kbStrength | The strength of the knockback the melee attack will apply. |
|
private |
This function is triggered by the melee animation at the peak of the sword swing. At that moment, the actual melee attack happens.
Scan for enemies in curRange radius of the attack point.
For each one found:
|
private |
Fires a projectile numProjectiles times, wtih delay seconds in between.
projectilePrefab | Reference the projectile the attack will instantiate. |
numProjectiles | Number of projectiles to spawn. |
delay | How much time between each projectile spawning, in seconds. |
void PlayerAttackManager.ShootProjectile | ( | GameObject | projectilePrefab | ) |
Spawn a projectile from the attack point and set it facing the correct direction. No cooldown overload. This will not start a cooldown and will ignore the current cooldown.
projectilePrefab | Reference the projectile the attack will instantiate. |
void PlayerAttackManager.ShootProjectile | ( | GameObject | projectilePrefab, |
float | cooldown ) |
Spawn a projectile from the attack point and set it facing the correct direction. Then start the attack cooldown.
projectilePrefab | Reference the projectile the attack will instantiate. |
cooldown | Length of the attack cooldown after this ability is triggered. |
void PlayerAttackManager.ShootProjectileBurst | ( | GameObject | projectilePrefab, |
int | numProjectiles, | ||
float | delay ) |
Will start a coroutine for ProjectileBurst, which F\fires a projectile numProjectiles times, wtih delay seconds in between.
projectilePrefab | Reference the projectile the attack will instantiate. |
numProjectiles | Number of projectiles to spawn. |
delay | How much time between each projectile spawning, in seconds. |
|
private |
Every frame, check if the user is pressing the melee key or projectile key.
|
private |
Reference the the player's animator.
|
private |
Objects on these layers which can be hit from the player's melee attacks.
|
private |
Reference to the player's's attack point. It's a point in space that's a child of the player, existing some distance in front of it. Projectiles spawn from the attack point, and melee attacks scan for enemies to damage from a certain radius around it.
|
private |
The melee knockback that will be used for the next attack. If no range parameter is given to Melee(), this will be set to meleeKnockback by default.
|
private |
The melee range that will be used for the next attack. If no range parameter is given to Melee(), this will be set to meleeRange by default.
|
private |
Reference to the projectile this attack will instantiate.
|
private |
Name of the animation to play.
|
private |
Key the user must press to activate this attack.
|
private |
True if attacking is on cooldown, preventing another attack from being used.
|
private |
Reference to the PlayerStatsHolder, which is responsible for managing the player's modifiable stats.
|
private |
Cooldown time for all attacks must wait after the projectile attack is used.
|
private |
Key the user must press to activate this attack.