Skill Tree being a Skill Tree

Author: Cameron Taylor

I ended up rewriting the skill tree multiple for the following reasons: first was having two different classes. One of which would be the Skill and hold the price, parents/children, and unlocked state. This was too slow for compile time so I pulled it out to put it inside a struct. Second was having all the structs be pointers pointing to each other so that every skill could be linked easily to their parent and child. This was also bad since every skill needed to be dereferenced. Not only did I need to hand write 87 skills for every since option. But I also needed to make sure that the branches were made correctly and they were connected which proved way more difficult in the end. I was passing by reference in multiple places which I thought would work but wouldn't because of a couple copy constructors in arrays.

To solve all of this I made a fixed array of 87 skill structs (since that is how many we have). Then when making every I would connect all of them to each other in the correct order. Once they are connected I would then finally push them into the array so that the copy constructor would copy them over with their children and parents still set. I then made a switch case of all 87 skills each to call their appropriate functions like raising health or increasing damage. I was told I could make a function pointer for them but in the end it would still be setting every single one of them and I would have to make the functions to in the classes in the end. Switch case allows for more debugging in the end right now.

Comments

Popular posts from this blog

Adding assets to every enemy -- Owen Meyers

Sphere to AABB collision