From f0c53827e41f51d6a893c7da0105d8e296a7869e Mon Sep 17 00:00:00 2001 From: Ny Bruker <robinhs@stud.ntnu.no> Date: Fri, 9 Dec 2022 17:51:03 +0100 Subject: [PATCH] Added `IsCharging` to indicate if the ability is charging or not. --- MrBigsock/Assets/Code/Core/Abilities/Base/AbilityEntity.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MrBigsock/Assets/Code/Core/Abilities/Base/AbilityEntity.cs b/MrBigsock/Assets/Code/Core/Abilities/Base/AbilityEntity.cs index 474e5a34..bdb968d6 100644 --- a/MrBigsock/Assets/Code/Core/Abilities/Base/AbilityEntity.cs +++ b/MrBigsock/Assets/Code/Core/Abilities/Base/AbilityEntity.cs @@ -24,12 +24,14 @@ namespace BigSock { public List<KeyCode> Keys { get; } + // Indicates whether or not the ability is charging. + public bool IsCharging => ChargeStarted > 0; // The time this ability has been charging. public float ChargeTime => Time.time - ChargeStarted; // The percent of maximum time the ability has charged for. - public float ChargePercent => (Ability.FireType == FireType.Charge && ChargeStarted > 0) + public float ChargePercent => (Ability.FireType == FireType.Charge && IsCharging) ? Math.Clamp(ChargeTime / Ability.MaxCharge, 0, 1) : 0; -- GitLab