InverNessian / SafeguardsOfLeyto

For development of my game by the same name.
1 stars 0 forks source link

Trigger Generation #27

Closed InverNessian closed 4 years ago

InverNessian commented 4 years ago

Going along with talents, I'll need a way to automatically generate Triggers and add them to gameObjects. Consider using the Start() method of the StatsManager class.

To-Do: Have a big switch statement that generates components based on the talent name passed into it.

Alternatively, look into using some kind of Map? That would make this much easier.

InverNessian commented 4 years ago

Found a super easy way to do this. AddComponent has an overload that accepts a string parameter. The string is the name of the component class you want. This means we can just pass in the talent list into a try/catch block! The catch block catches TypeLoadExceptions, since we are using Type.GetType(stringname). If no type is found, it catches that.

This method is tested and works.