From 10754bf09257f07a9c8c02f98d6c0eb9ef2dbe55 Mon Sep 17 00:00:00 2001 From: Ny Bruker <robinhs@stud.ntnu.no> Date: Tue, 1 Nov 2022 17:59:37 +0100 Subject: [PATCH] Added ability properties for charging. --- .../Code/Core/Abilities/Base/BaseAbility.cs | 29 +++++++++++++++++++ .../Code/Core/Abilities/Base/IAbility.cs | 23 +++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/MrBigsock/Assets/Code/Core/Abilities/Base/BaseAbility.cs b/MrBigsock/Assets/Code/Core/Abilities/Base/BaseAbility.cs index a652d433..5a788ea1 100644 --- a/MrBigsock/Assets/Code/Core/Abilities/Base/BaseAbility.cs +++ b/MrBigsock/Assets/Code/Core/Abilities/Base/BaseAbility.cs @@ -61,6 +61,26 @@ namespace BigSock { public float HPCost { get; protected set; } + /* + -------------------- + Charging related properties. + -------------------- + */ + + /* + What kind of firetype this ability uses. + */ + public FireType FireType { get; protected set; } + + /* + The minimum time in seconds the ability needs to be charged. + */ + public float MinCharge { get; protected set; } = 0.1f; + + /* + The maximum time in seconds the ability before the ability is fully charged. + */ + public float MaxCharge { get; protected set; } = 0.2f; @@ -71,6 +91,15 @@ namespace BigSock { */ public bool Use(IAbilityParam par) { var actor = par.Actor; + + // Check the charging + if(FireType == FireType.Charge) { + // Check that we charged the minimum time. + if(par.ChargeTime < MinCharge) return false; + + // Calculate how much optional charging we did. + par.ChargeTimePercent = Math.Clamp(par.ChargeTime - MinCharge / MaxCharge - MinCharge, 0f, 1f); + } // Check that the ability is cooled down. if(Ready) { diff --git a/MrBigsock/Assets/Code/Core/Abilities/Base/IAbility.cs b/MrBigsock/Assets/Code/Core/Abilities/Base/IAbility.cs index 99cdd8be..e746fa82 100644 --- a/MrBigsock/Assets/Code/Core/Abilities/Base/IAbility.cs +++ b/MrBigsock/Assets/Code/Core/Abilities/Base/IAbility.cs @@ -60,6 +60,29 @@ namespace BigSock { + /* + -------------------- + Charging related properties. + -------------------- + */ + + /* + What kind of firetype this ability uses. + */ + FireType FireType { get; } + + /* + The minimum time in seconds the ability needs to be charged. + */ + float MinCharge { get; } + + /* + The maximum time in seconds the ability before the ability is fully charged. + */ + float MaxCharge { get; } + + + /* ----------------------------- Add in something for costs. -- GitLab