From 5dad49acf72f9aae7ea4acc29d81ff54f7c2de35 Mon Sep 17 00:00:00 2001 From: Ny Bruker <robinhs@stud.ntnu.no> Date: Tue, 4 Oct 2022 15:50:34 +0200 Subject: [PATCH] Implemented mana, stamina & hp costs. --- .../Code/Core/Abilities/Base/BaseAbility.cs | 23 +++++++++++++++++++ .../Code/Core/Abilities/Base/IAbility.cs | 18 +++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/MrBigsock/Assets/Code/Core/Abilities/Base/BaseAbility.cs b/MrBigsock/Assets/Code/Core/Abilities/Base/BaseAbility.cs index f19870ed..9937544a 100644 --- a/MrBigsock/Assets/Code/Core/Abilities/Base/BaseAbility.cs +++ b/MrBigsock/Assets/Code/Core/Abilities/Base/BaseAbility.cs @@ -43,6 +43,23 @@ namespace BigSock { + /* + The mana cost of the ability. + */ + public float ManaCost { get; protected set; } + + /* + The stamina cost of the ability. + */ + public float StaminaCost { get; protected set; } + + /* + The hp cost of the ability. + */ + public float HPCost { get; protected set; } + + + /* @@ -54,6 +71,9 @@ namespace BigSock { // Check that the ability is cooled down. if(Ready) { //> Handle checking costs here. + if(ManaCost > 0f && actor.Mana < ManaCost) return false; + if(StaminaCost > 0f && actor.Stamina < StaminaCost) return false; + if(HPCost > 0f && actor.HP < HPCost) return false; // Activate the ability. var res = Activate(actor, target); @@ -62,6 +82,9 @@ namespace BigSock { if(res) { NextTimeCanUse = DateTime.Now + Cooldown; //> Handle paying the cost (HP, mana, stamina) here. + if(ManaCost > 0f) actor.Mana -= ManaCost; + if(StaminaCost > 0f) actor.Stamina -= StaminaCost; + if(HPCost > 0f) actor.HP -= HPCost; } return res; diff --git a/MrBigsock/Assets/Code/Core/Abilities/Base/IAbility.cs b/MrBigsock/Assets/Code/Core/Abilities/Base/IAbility.cs index 07034791..0bcd5fcb 100644 --- a/MrBigsock/Assets/Code/Core/Abilities/Base/IAbility.cs +++ b/MrBigsock/Assets/Code/Core/Abilities/Base/IAbility.cs @@ -42,6 +42,24 @@ namespace BigSock { bool Ready { get; } + + /* + The mana cost of the ability. + */ + float ManaCost { get; } + + /* + The stamina cost of the ability. + */ + float StaminaCost { get; } + + /* + The hp cost of the ability. + */ + float HPCost { get; } + + + /* ----------------------------- Add in something for costs. -- GitLab