Friday 8 January 2016

Character Creation Prototype

As our game is an RPG it made sense for us to include a character creation system. We opted to have character classes that would contain pre-determined stats; these stats would improve through levelling up. 
The classes themselves are based on particular play styles, for example we have the Bruiser class which is a melee oriented class. The hope is that for the vertical slice the inherent stats will affect gameplay, for example in the turn based combat system the damage done to the enemy will be based on their weapons damage stat. Depending on your character's Might stat a certain base damage modifier will be added to that weapons damage stat.

At the end of development the character creation system should be in its own scene once the player selects "New Game" in the main menu. For now I have made a script that shows the 4 main classes in Unity's basic GUI Layout, once the class has been picked and the "Create" button selected the stats and name of the class are generated in the console.


I initially created a script called BaseCharacterClass, the idea of this script/class is that when I would eventually go on to make the 4 individual classes the basic values that they would use in the code, such as the 6 main stats:
Might
Endurance
Intelligence
Presence = Charisma
Awareness = how good the player's senses are
Chance = Luck
Could be called from this BaseCharacterClass script, this would save me the trouble of remaking the basic values for each class script.

I used public getters and setters in the BaseCharacterClass script. This would allow me to call up the values within other scripts. This works by storing private values such as an integer (a whole number) and then by making a public integer that corresponds to the private integer and typing out the syntax of the getter and setter in {} parenthesis, for example:

private int might;

public int Might
{
                                   get{return might;}
                                     set{might = value;}
}

 get{return might;}: get simply reads the following text, in this case "might" 
set{might = value;}: set gives the value, the value in this instance is an integer and consequently is a whole number
The code also uses String, the sole value of a sting is text like the value of an integer is a whole number.


Next I wrote the first class script, referred to as BaseBruiserClass. I removed MonoBehaviour and instead of inheriting MonoBehaviour the script would inherit the BaseCharacterClass script. Since I am now inheriting from my BaseCharacterClass script when I type, for example, CharacterClassName (which was one of my public strings in the BaseCharacterClass script) it will appear in a drop down list when I begin to type it out similar to if I were typing out another common piece of syntax like "void"; and I will be able to assign a value to it, in this case its a string so the value is text based and since I am using it to name the class I would type something like this:

CharacterClassName = "Bruiser";

Likewise, since I am calling the stats within this BaseBruiserClass script and they are integers rather than assigning them a text value I would assign them a whole number value:

Might = 10;

Capital M in might as I typed it as such in the BaseCharacterClass script when I typed:

public int Might
{
                                   get{return might;}
                                     set{might = value;}
}

Following this I made a new c# script called BasePlayer, which functions almost the same way as the BaseCharacterClass script but the BasePlayer script will be used to store the inherent information of the player themselves, such as the player's level and current XP etc. But I shall continue with that script later.


Lastly I created a new c# script called CreateNewCharacter. This script shall be used to code the initial character creation screen.
I started off by making 4 private bool/boolean's, a boolean stores a true or false value which can be declared in a later line of code; namely an if statement. Each one represents 1 of the 4 classes and where named for that purpose:

private bool isBruiserClass;

This can be spoken informally as "isBruiserClass True or False", that is essentially what we are trying to say in this variable.

isBruiserClass = GUILayout.Toggle(isBruiserClass, "Bruiser Class");

This line of code uses Unity's GUILayout.Toggle, this will display a "tick" box on screen followed by Bruiser Class, this for the players sake to be able to select a class. I repeated this line of code for all 4 classes.
After this I used an if statement to determine whether the tick boxes had been ticked, and else if to follow on to the tick boxes of the other classes to check if they had been ticked.

No comments:

Post a Comment