Now that the player is able to buy skills in the skill tree that actually effect the player character, I needed to implement a way for the player to interact with the Tree of Sorrow from within the Hub scene.

To create a way for the player to interact with the Tree of Sorrow, I gave it a childobject with a PolygonCollider2D component and set it to trigger. Then, I created a new C# script and called it SkillTreeZone.
This script constantly checks for any other colliders that trigger its collider component. If the player collides with it, a playerInside bool is set to true. If this is the case and the player presses ‘E’ then the Skill Tree UI is set to active and an isOpen bool is set to be active, along with the active status of the Skill Tree UI.

This isOpen bool then determines whether the player’s AttackNew and PlayerControllerNew script is enabled, disabling them if the Skill Tree UI is enabled. Furthermore, this isOpen bool controls whether the cursor is visible on screen, enabling it if the Skill Tree UI is enabled and disabling it otherwise.
Then, if the player presses ‘E’ while the Skill Tree UI is enabled, it gets toggled off, allowing the player to move and attack again.

Saving the player’s Tree of Sorrow progress

An extremely big issue with the current Skill Tree, is that if the player dies in the dungeon after unlocking skills at the skill tree. When they respawn at the skill tree, all of their progress is erased, despite still having the effects from the skills on the player character.
However, this was essentially the same issue I had with the player character not being able to keep the effects from their skills when going to another scene in the game – an issue I had already fixed by using the PlayerStatsManager singleton. However, this was a much more complex version as with the skills effecting the player, I only had to change and store certain ints in the PlayerStatsManager. But in this case, I had to store data about: Which skills were unlocked; what skills should stay locked and what skills were already maxed out.
After unsuccessfully trying to fix this issue, I explained the situation to Ross and asked for his help:

Essentially, what Ross had done to fix this issue was adding a Dictionary<> (A Dictionary is is a collection that stores key-value pairs, like a real-world dictionary where you look up a word (key) to get its definition (value) – Microsoft Documentation) to the PlayerStatsManager, this Dictionary would track each SkillSO on every SkillButton’s SkillSlot script and would store its currentLevel int and then runs the UpdateUI() method every time a SkillSlot was enabled. As this dictionary is stored in a singleton, this data is never destroyed even when loading a new scene in the game.

On the SkillSlot script, every time that the a Skill Button with the SkillSlot script was enabled, it would check if the skill was not locked. If it was locked, it calls the IsSkillUnlocked() and GetSkillLevel() methods from the PlayerStatsManager script.
