Refactoring Nested Switch Statements
I'm defining a character's race and class via the inspector and I need to initialize some components (ai, animations and some other things) based on those parameters.
My initial thought was to do some switch statements but I ended up needing to nest the class switch inside each race switch which led to pretty much hell.
I'm trying to refactor it into something more manageable then just a bunch of switch statements (if not possible then I'll just spread the switches through separate methods) and I thought about the Strategy pattern but I have no idea how to do it for nested statements.
It would be great if you could help, thanks!
Your answer
![](https://koobas.hobune.stream/wayback/20220612040437im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Having an issue with using an Enum and using a string variable 0 Answers
How can I avoid using switch and for too much? 2 Answers
Is OnMouseUpAsButton() can be called only once ? 2 Answers
Simple Camera Switch Using C# 3 Answers
Change sprite collection 1 Answer