- Home /
Coding a class swapping system
The mechanic I'm trying to get to work would be the player runs around and can switch between 5 fighting styles but picking up different totems. Here is a quick example;
The player would start off without a totem and they grab a spear master totem, letting them use spears and level up a spear skill tree, eventually they find a Wizard Totem and switch to it letting them use spells and level up a spell skill tree. If the player comes across another spear totem they can switch back to where they were in the spear skill tree.
I was thinking of having a script for each individual fighting style that would activate while the player had a specific totem, either that or a state system where each style is a state (like how in mario he has racoon, grown up, and fire flower). Any kind of help starting this off would be great. Also, i intend to program in JS (most experience i have is with JS).
Answer by HappyMoo · Jan 03, 2014 at 12:22 PM
Use classes to manage your Skill Trees Logic, but don't make them MonoBehaviours. Then have a Single MonoBehaviour on the Player that keeps track of all the SkillTrees and switches between them and calls the code in the Skills that actually does something to the Player/World. It also keeps track of which SkillTree/Totem you've actually seen/used at least once, so it knows which SkillTree is current, which you already had but are dormant and can be shown to the Player and which the Player didn't find yet, so you don't even let the Player know that they exist.
The details of how that class hierarchy would look like, depends on what leveling up a Skill Tree actually means for your game and how big the Trees get etc.