Each character class has multiple roles that they can fill. Falling into one of three categories: damage, support, and tank, each role is diverse and different class/role combinations will need to be experimented with to find the most effective for each battle. The menu functionality was fairly simple to integrate into the basic menu.
Because I already had an extra menu system created using integer's to decide what information to display and change, it was simply a matter of taking into account what the current set "characterClass" was, checking to see if the characterClass had even been set, then allowing that integer to change the two-variables available in the menu. Some classes allow for Damage and Support, others for Support and Tank, and lastly for Damage and Tank.
I also wanted to make sure the player was unable to set a character role for a specific class, and then change to a class which does not offer that role; this was simple to counteract by adding a line of code which tells the script to remove the current "characterRole" integer from the PlayerPrefs if the "characterClass" integer is altered in some way. I felt like this was an efficient way to keep the problem from popping up. Now anytime you set a new character class, the character role must be reset as well.
From there I realized there was an issue with the way I had written the script for adding a character to the roster. If the game was reset, the character roster would also be reset; which seemed fine at first thought, but the more I thought about it - it seemed like something that would get really annoying if you had to constantly reset your roster every time you started the game back up. I also didn't want the player to be able to add a character to the roster and then change the characters class, resulting in the character role being revoked but the character left in the roster without any form of role to play out.
The best thing I could think of to combat this was to create another PlayerPrefs integer for "inRoster", and like the characterRole integer, this too would be reset if the playerClass was changed. This allowed the roster to be saved between sessions, and through any scene changes automatically; only being changed if the player decides to remove them from the roster (through direct removal or indirect removal by class or role change). Because the integer for characterRoster is simply a 0,1 system it was easy to allow a single button to do the direct changes right on the Character Menu; without the need of any sub-menu's.
I would love to give a code-snippet or two, but in all honesty the amount of code required to even display the amount of information encompassed is a couple-hundred lines per-character; and is specifically tailored to only fit this system. With that said, if anyone really wants an example for their own project, or learning, ask in the comments and I'll try and accommodate you with some new examples.
No comments:
Post a Comment