Another design question here. I am creating enemies in my JRPG and have come to another sticking point.
Namely, do you create a single "Enemy" class and then instantiate objects of that type, then load the respective properties from say a flat file or database like "Bestiary";
Orc = 1;
Goblin = 2;
Skeleton = 3;
DireWolf = 4;
Zombie = 5
Enemy Orc = new Enemy(EnemyType.Orc);
Enemy Zombie = new Zombie(iEnemyType.Zombie);
Or do you create a different sub-class for each type of enemy, and then hard code the properties for that class?
Or is it just a case of personal preference?
I hope that all makes sense and thanks for the help.
Members - Reputation: 120
Posted 18 August 2014 - 02:21 AM
Crossbones+ - Reputation: 7079
Posted 18 August 2014 - 04:09 AM
This is a typical problem where composition and data oriented design should be preferred. Reason is that inheritance yields in more maintenance problems due to needlessly deep hierarchies, and design work would be burdening the programmer.