Abillity system for turn based strategy
Hi,
I'm working on a turn-based strategy rpg. At the moment, I'm making an ability system using Scriptable Objects, but as I'm quite new to unity, I'm beginning to wonder if this is the best way to go at it.
The way it works at the moment: I have a class called CharacterAbility which is a scriptable object which defines common features and functions of different character abilities. Each ability then inherits from this class and overrides its functions, for example, CleaveAbility: CharacterAbility. Each character has a list of abilities, and I drag the scriptable object into this list in the inspector to determine which abilities a character has access to.
There are mainly two issues I'm having at the moment:
A: Scriptable object data persists after play mode ends, which makes testing a chore as an ability will still be on cooldown if I exit and reenter play. At the moment I have solved this by resetting important values in the OnEnable() function, but I'm not sure if this will create issues down the line (?)
B: Many characters on the map will have the same abilities. Since abilities reference a single scriptable object asset, that means that the ability will go on cooldown for all characters when one uses it, which is obviously not ideal. I think I can work around this by instantiating an instance of the ability for each character (?), but I'm wondering if this is a good way of doing things.
What are the best solutions for the issues above? Is it okay to use the OnEnable function like this and to instantiate copies of the abilities that are used by several characters, or are scriptable objects simply not the best fit for my use case?
CharacterAbility class is below:
public class CharacterAbility : ScriptableObject
{
public string abilityName;
public Sprite abilityIcon;
public Sprite coolDownIcon;
protected int apCost;
private int baseCooldown;
public int coolDown;
public bool isOnCooldown;
public bool isActive = false;
private void OnEnable()
{
isOnCooldown = false;
coolDown = 0;
}
public virtual void OnAbilityStart()
{
isActive = true;
}
public virtual void OnAbilityFinished()
{
isActive = false;
}
public virtual bool CheckAbilityValid()
{
}
public virtual void OnAbilityTick()
{
}
public virtual void OnExecute()
{
}
}