I'm using Unity3D and trying to achieve the following. I want to store in the class some parameters as well as "special rules" - which ment to be the functions in this or other class.
Ideally I would want something that behaves like this:
public class Weapon
{
public DamageHandler damageHandler; //script that have all special rule functions
public string weaponName;
public int damage;
public ???? specialRule; //this is the rule of interest
public void DealDamage()
{
damageHandler = GetComponent<DamageHandler>();
damageHandler.specialRule(damage); //call the function that is set in Weapon Class
}
}
I know that I can save specialRule as a string and use reflection. Is there any other way/better way to handle such situation?