This is my abstract class:
abstract class Enemy
{
protected static abstract float HEALTH
{
get;
}
float health;
void someMethod()
{
health = HEALTH;
}
}
This is my derived class:
abstract class BadGuy : Enemy
{
protected override static float HEALTH
{
get { return 1; }
}
}
Mr. Compiler says I can't make the member HEALTH static as well as abstract in the Enemy class.
My goal is to force each child class to have a static or constant field which can be accessed from the parent class.
Is there a solution for this? If not, what's the most elegant workaround? Making the property non-static?