I’m creating a videogame and in this video game there are different classes. Every class has the same data structure of every other class but different values. For example a class has 3 element: class name, starting health points and class picture path.
Which is the best practice to do something like this?
My best guess is to create a class and then create an instance for every ingame-class with the corresponding value
Explanatory example:
public class InGameClass {
public string className;
public int startingHP;
public string picturePath;
public InGameClass(string newClassName, int newStartingHP, string newPicturePath) {
className = newClassName;
startingHP = newStartingHP;
picturePath = newPicturePath;
}
}
And then I create a class that got all the instantiated class
public class InGameClasses {
public InGameClass Mage = new InGameClass("Mage", 90, "Resources/Class/Mage");
public InGameClass Warrior= new InGameClass("Warrior", 100, "Resources/Class/Warrior");
}
Francesco Laghetti is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.