Adding on to the answer given by derHugo, just in case someone else stumbles across this. I'm using the method suggested, but found that in order to "import" the types at runtime that [RuntimeInitializeOnLoadMethod]
had to be set used. There are probably other ways, too, but here's the 3 move files I ended up with for answer completion's take.
MoveManager.cs
public static class MoveManager
{
public static List<Move> Moves = new List<Move>();
}
Move.cs
public class Move
{
public string name;
public string description;
public Target target;
public int power;
public float accuracy;
public int cost;
public game_Type type;
public Style style;
public Move(
string name
, string description
, int power
, float accuracy
, int cost
, string typeName
, string styleName
, string targetType
)
{
this.name = name;
this.power = power;
this.accuracy = accuracy;
this.description = description;
this.type = game_Types.getByName(typeName);
this.style = MasterStyles.getByName(styleName);
this.target = new Target(targetType);
// a static class member is simply accessed via the type itself
Debug.Log("Registering " + name + " type!");
MoveManager.Moves.Add(this);
}
}
move_basic.cs
class move_basic
{
[RuntimeInitializeOnLoadMethod]
static void OnRuntimeMethodLoad()
{
// Name this move
string name = "Attack!";
// Describe this move
string description = "Strike out at the enemy with tooth, claw, weapon, or whatever else is available!";
// Choose the type of target this move is for
// self/ally/selfAlly/enemy/enemies
string target = "enemy";
// The move typing - This determines cost reduction as well as potential attack bonuses
string typeName = "physical";
game_Type type = game_Types.Types.Find(x => x.name == typeName);
// The move style - This determines additional bonuses and modifiers
string styleName = "martial";
// Style style = ??
// Power of the move, base/'normal' power is 50.
int power = 50;
// Accuracy of the move, base/normal is 90
int accuracy = 90;
// MP Cost of the move
int cost = 0;
Move mv = new Move(name, description, power, accuracy, cost, typeName, styleName, target);
}
}
The next step, now that I've confirmed this works will be to add methods to the registered moves which is where the real magic is IMO.
This seems like a pretty optimal solution when you need to create an easily extendable library of objects which may need to contain callable methods. If not for that need, it probably would have been better to import properties from a csv or something.
I'm pretty new to unity and game design in general, so I'm more than happy to have this post edited/corrected/improved to assist future searchers.