Today I set out to finish the basic GUI functionality for outside of battle. What this included, and why it took 3 days, was to make sure that all of the character's levels were tracked by a save system, along with their class type, and class role. From these 3 stats, the game will be able to read the integers given by the PlayerPrefs (save information) and translate that information over to the basic attacks and rotation that the characters will perform inside of battle. Once the information is kept by the system, it can easily be accessed with new menu options using if statements to hide key abilities that each character can use.
The other functionality for the basic menu was to allow you to change your character's class as you need. Before, you were going to be limited to 2 of each of the 8 classes, allowing you to utilize unique roles for similar characters if you desired. This was, in truth, a limitation I was placing on the characters because of a lack f programming knowledge on my-part. Well, after a few hours of trial and error I was able to create a menu system that could read the current class, and allow the player to change that class using a simple menu system. I felt like the average player is not going to want a 10-person team of the same class, but if they do they should have the ability to do so.
This was accomplished by creating a sequenced loop for menu's. When the player presses the desired characters button in the roster menu, it reads the character's current class as an integer, and translates that integer into a string to display in the menu. Next to that string I created a button, which offers the player to change the character's class. If the player presses the button, a sub-menu appears at the bottom of the screen which sets a new integer to be written in the form of "newClass". This new class integer is also translated by the script into a string which is displayed in the form of a new button in-place of the "change class" button asking the player to "confirm new class: "class_name"" which when presses, changes the player-prefs for that character to whatever the integer value of "newClass" is. The effect is immediately seen on the menu, where the new class is now displayed as the current class of the character.
In order to prevent any bugs where the player may keep the sub-menu open, I created a method for the sub-menu to run from using an integer system. If the integer value for the method returns "null" then the menu is no longer displayed, and the "newClass" integer is set back to "null" as well. This prevents the player from opening the sub-menu and then switching characters; thereby accidentally changing the class of the wrong character. This integer system will also make it easier in the future to prevent similar issues with all sub-menu systems, as this is the same place that professions and such will also take place.
If you are interested in how this menu system was accomplished, here's an example:
The sub-menu's method (This tells the method to allow an integer to be allocated for use as edM):
void ExtraDisplayMenu (int edM)
{
extradisplayMenu = edM;
//end extra display menu
}
The call-to script (This tells the method to use integer 1 in-place of edM):
if (GUI.Button(new Rect(210,75,200,20), "Set New Class"))
{
ExtraDisplayMenu (1);
}
This is the sub-menu script (Tells the script what to display when a specific integer is called):
if (extradisplayMenu == 1)
{
GUI.Label (new Rect(0, 0, 200, 20), "Set Player Class");
}
No comments:
Post a Comment