diff --git a/MrBigsock/Assets/Code/Core/Abilities/Base/AbilityEntity.cs b/MrBigsock/Assets/Code/Core/Abilities/Base/AbilityEntity.cs index 2ef904442dc941daba5bc50fdfe3611810bdbba7..8503f3e8968ca216f344c3120da7c0282f328c95 100644 --- a/MrBigsock/Assets/Code/Core/Abilities/Base/AbilityEntity.cs +++ b/MrBigsock/Assets/Code/Core/Abilities/Base/AbilityEntity.cs @@ -18,13 +18,26 @@ namespace BigSock { public int Index { get; } // The time this ability started charging. - public float ChargeStarted { get; } + public float ChargeStarted { get; set; } // The keys bound to this ability. - public List<KeyCode> Keys { get; set; } + public List<KeyCode> Keys { get; } + // 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) + ? Math.Clamp(ChargeTime / Ability.MaxCharge, 0, 1) + : 0; + + + // How far into the cooldown the attack is. + public float CooldownPercent + => (float) Math.Clamp((DateTime.Now - Ability.NextTimeCanUse + Ability.Cooldown) / Ability.Cooldown, 0, 1); + public AbilityEntity(IAbility ability, int index, List<KeyCode> keys = null) { if(ability == null) throw new ArgumentNullException(nameof(ability));