Thursday, March 20, 2014

2 Week Coding Project - Day 5 : Character Roster Selection

I wanted to focus on character selection, so I needed to figure out a good way to reference the characters in the game, without actually having to call each object all the time. This was easiest done by creating a series of bools and integers that worked between the "persistentScript" and the "menuScript" to tell the menu which characters have been selected and what menu options to display from that information.

The persistentScript holds the integer variables for "character#Available" (numbers 1-16); as well as an integer variable for "characterParty". The GUI then checks to see if the persistentScript variable is "0" and if so, displays a menu option allowing you to "Add to Party". If the button is pressed, then the persistentScript variable is then set to 1 and the menu is no longer displayed. It also removes 1 from the variable for characterParty; which when it reaches 0, the option for adding more party members is removed.

Because the persistentScript is not reloaded after scene change, this allows the next scene with the Build script to reference which characters were selected by the player. The next step will be to change the build script to check the integer value of character 1, and if it returns 1, then it will allow that character to be placed on the play-field; and then set the variable integer to 0 for that character. If it returns 0, then the build script will check the integer value of character 2 and the process will start all over.

This process will look something like this:
-------------------
if(pS.character1Available == 1)
{
GameObject block = (GameObject)Instantiate(Resources.Load ("Block1"), RetAdd.transform.position, Quaternion.identity);
block.name = "Block1";
pS.character1Available -= 1;
}
if(pS.character1Available == 0)
{
if(pS.character2Available == 1)
{
GameObject block = (GameObject)Instantiate(Resources.Load ("Block2"), RetAdd.transform.position, Quaternion.identity);
block.name = "Block2";
pS.character2Available -=;
}
if(pS.character2Available == 0)
{
if(pS.character3Available == 1)
{
//extend script here
}
}

}
-------------------
The script will continue like this until all 16 character integers have been checked. After character 16 has been checked, the build script will then turn placement mode off and the fight will start.

No comments:

Post a Comment