things
This commit is contained in:
parent
a17810ffeb
commit
4e91f448c9
826 changed files with 66 additions and 8 deletions
40
Assets/Scripts/UnitScripts/Capacities/BaseCapacity.cs
Normal file
40
Assets/Scripts/UnitScripts/Capacities/BaseCapacity.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class BaseCapacity : MonoBehaviour
|
||||
{
|
||||
[field: SerializeField] public float MaxMana { get; private set; }
|
||||
[field: SerializeField] public float Mana { get; private set; }
|
||||
[SerializeField] private float manaCost;
|
||||
protected AbstractUnit _unit;
|
||||
|
||||
|
||||
|
||||
// Called every frame
|
||||
protected virtual bool CapacityCall()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void AddMana(float manaAdd)
|
||||
{
|
||||
Mana = Mathf.Min(Mana + manaAdd, MaxMana);
|
||||
}
|
||||
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
_unit = GetComponent<AbstractUnit>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Mana >= manaCost)
|
||||
{
|
||||
bool capacityLaunched = CapacityCall();
|
||||
if (capacityLaunched) Mana -= manaCost;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue