I have a question about classes. I am working on an RPG, and rather than have a separate script for each enemy monster, I am just going to have a "monster" class that serves as the template for each monster, then have each monster be a variant on that class. Then, I am going to have a template "monster" script, so when I want to spawn three "fire monsters" I was just going to have the variables in the monster script be filled with the data from the fire monster class variant. My question is, how can I have the variables in a script automatically be filled with the data from a class? Also, how can I use that in conjunction with instantiate (so I could spawn the monster template prefab and then control what class variant it is filled with).
Here is an example of what I want: The Monster template class
class Monster{
var name;
var HP;
}
Here is the Fire Monster Sub class
var fire_mon = Monster();
fire_mon.name = "Charmander";
fire_mon.HP = 20;
Here is what the monster script (which would be attached to the monster prefab).
var name = String;
var HP = Int;
//other code
and here is what I would want that instance of the monster script to look like after I have applied the fire_mon class variant:
var name = Charmander;
var HP = 20;
//other code
I know that was a long and complex question, thanks :)