Unity: C# Spell System

Unity: C# Spell System

I couldn't find any proper tutorials in the internet how to make one so I tried it myself. I've written a base "Skill" class with methods like Cast(), DealFlatDamage(), ShootProjectile() and they all work so far. But I also wanted to implement trigger methods for passive spells: OnDeath(), OnKilled(), OnProjectileHit(). 
First Question: Is this a wrong way to go? Because I couldn't find anything like this in the internet.
Second Question: The idea was to create new classes inheriting from this base class and the base class calling all the "On..."-methods of each derived class. How can I do this?
Would appreciate help!

Solutions/Answers:

Answer 1:

There is no right or wrong way to do this, but here is an alternative approach.

interface IOnDeath
{
    void Action( /*some context here*/ );
}

class Skill
{
    public List<IOnDeath> OnDeathEffects;
}

class OnDeathNova : IOnDeath
{
    public void Action(...)
    {
        /* creates an outward facing ring of projectiles */
    }
}

...
    skill.OnDeathEffects.Add(new OnDeathNova());
...

This gives you a very dynamic approach, and lets you modify things at run-time. Maybe you want to make a spell deal double damage when a buff is applied. Maybe you want to have it bounce. All these things could be hardcoded into a single class, but it would get messy fast. This approach lets you give each “effect” their own separate implementation.

References