I have 3 classes. I use aggregation to extend main class. How I can rise events from main class, when I perform operation in UnitHealth and UnitSkill classes?
I can duplicate event in aggregated class (UnitHealth, UnitySkills), and subscribe on it from Unit (main class). But it seems to me that it is bad idea.
public class Unit
{
public static event EventHandler HealthChanged;
public static event EventHandler SkillUsed;
private UnitHealth health;
private UnitSkill skill;
}
public class UnitHealth
{
void ChageHealh()
{
}
}
public classUnitSkill
{
void UseSkill()
{
}
}
Aucun commentaire:
Enregistrer un commentaire