- Home /
Design Question
Concept question
Hey,
I'm making a 2D game and want to "revamp" my enemies. Is it a good idea if i have 1 class where every attribute from the enemies is declared:
Simple example :
public class EnemyAttributes : MonoBehaviour
{
public int enemyLevel = 100;
public int enemyHp = 500000;
public int enemyMp = 10000;
public int avoid = 150;
public int enemyKnockback = 4000;
public int enemyExp = 1000000;
void decereaseHp(int amount)
{
enemyHP -= amount;
}
And then building some classes as child for the attribute gameobject ?
e.g.:
Class named decreaseEnemyHp
and there its calculating all the things ... like is the enemy dead or how much amount of hp really will be decreased ... because of the avoidability.
Regards,
LifeArtist
Ps.: If you dont understand something ... ask me ;P
As your question stands right now, it is a design question. We ask that design questions be posted to Unity Forums. Unity Answers focuses on single specific technical questions.
Right now your question is difficult to answer because we don't have context. You could build a base class and derive other classes from this for different enemy types. But looking at the data, an alternate would be to not derive this class from $$anonymous$$onoBehavior and simply have the data reference in the component. If you post your question on Unity Forums, it will also be helpful to them to have context.
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to make the camera is not break trough object? 2 Answers
Would painting a solid colour (such as black) on unity terrain help performance? 1 Answer
Array weapons Wheel scroll switch 1 Answer
How Do You Select A Game Object By Using the Left Mouse Button? 2 Answers