I suppose you can use reflection to achieve the setting of stats, as long as Unity3D allows it. I should warn you however reflection is relatively slow so you should look at your design before implementing reflection. The method calling is simple, make the base Hero class's Alarms() virtual and override it in the children classes.
The output of the following for instance is
Hero's MP is 40/100
Hero's MP is 40/400
Wizard's Alert!
class Program
{
static void Main()
{
BaseHero hero = new Wizard() {MaxMp = 100, Mp = 40};
Console.WriteLine("Hero's MP is {0}/{1}", ((Wizard) hero).Mp,
((Wizard) hero).MaxMp);
hero.SetStat("MaxMp",400);
Console.WriteLine("Hero's MP is {0}/{1}", ((Wizard)hero).Mp,
((Wizard)hero).MaxMp);
hero.TriggerAlert();
}
}
class BaseHero
{
public void TriggerAlert()
{
Alert();
}
//This will only fire if the child classes do not override,
//or if the child class calls base.Alert()
protected virtual void Alert()
{
Console.WriteLine("Base Alert!");
}
//Reflection to set fields, requires the name of the field and the value
public void SetStat<T>(string statName,T value)
{
FieldInfo field = GetType().GetField(statName);
field.SetValue(this, value);
}
}
class Wizard:BaseHero
{
public int Mp = 0;
public int MaxMp = 0;
protected override void Alert()
{
Console.WriteLine("Wizard's Alert!");
//Uncomment this line to have both the Wizard's alert and the base hero's alert fire
//base.Alert();
}
}