Hello everyone. For the last few days I've been trying to come up with a good way to implement spell system for my turn-based (grid) game. I recently found out about Scriptable Objects and they seem like a perfect tool for implementing this system. First I started with thinking about different types of spells and effects that I'd have in a game. So what I came up with is, buffs and debuffs (single and multi target, last through X turns), auras, direct damage spells (single target, aoe(multiple tiles)) with or without projectiles and on-hit effects. I believe SOs would be a good idea because they would make it easy(hopefully) to customize different spells just through inspector.
I'm having a hard time with starting all of this. I have an idea but I feel like it's very inefficient and just a mess overall. Ok, so direct dmg spells seem like an easiest thing of the bunch, but for buff/debuffs, I think I should have an array of those in each Unit class so I can add them when they are cast and check at the start of turn if they should be removed or not. First thing that came to my mind is make a base abstract class for all spells.
public abstract class SpellEffect : ScriptableObject {
public string spellName;
public string description;
public Sprite icon;
public float cost;
public abstract void Cast();
}
And then make a sub-class for each type.
public class StatusEffect : SpellEffect {
public int numOfTurns;
public float modAmount;
public float modPerTurn;
public StatType statType;
public TargetType targType;
public override void Cast() {
}
}
public class DirectDamage : SpellEffect {
public float damage;
public Projectile projectile;
public StatusEffect debuff;
public bool useProjectile = false;
public bool useDebuff = false;
public TargetType targType;
public override void Cast() {
}
}
Something like that. I really don't know where or how to begin exactly. I would really appreciate some help and pointers.
Thanks.