- Home /
Creation of RPG Class Stat Presets?
Hello. So i want to have about three different classes for my game. The usual ones like Warrior,Archer and Wizard. How exactly should i approach the creation of the stat presets?I mean what i want is when you enter the game you will have this "Create Character" button and when you press it three more buttons will appear, each one for each of the classes. And of course there should be three different stat presets for each button/class. For example:
Warrior(Strength:12,Vitality:12,Dexterity:10,Intelligence:8) Archer(Strength:10,Vitality:11,Dexterity:12,Intelligence:9)
Should i just create three simple scripts with the variables i want and attach them to the different buttons so that when the Warrior button is pressed, the Warrior script is enabled and then create a whole Statistics system for the game OR something simpler/harder?
Thanks!
Answer by Landern · Mar 14, 2013 at 01:31 PM
You can break it up and type out generically the character stats and such.
// RPGClass.cs
public class RPGClass
{
/// Name of the class(warrior, etc)
public string ClassName { get; set; }
public int Strength { get; set; }
public int Vitality { get; set; }
public int Dexterity { get; set; }
public int Intelligence { get; set; }
}
// Character.cs
using UnityEngine;
using System.Collections.Generic;
public class Character : MonoBehavior
{
private List<RPGClass> m_Classes;
void Start()
{
m_Classes = new List<RPGClass>(); // could populate collection during instantiation if you wanted
m_Classes.Add(new RPGClass() { ClassName = "Warrior", Strength = 12, Vitality = 12, Dexterity = 10, Intelligence = 8 };
m_Classes.Add(new RPGClass() { ClassName = "Archer", Strength = 10, Vitality = 11, Dexterity = 12, Intelligence = 9 };
}
}
Thanks for your answer. I actually did something myself but it's just some GUI and the textasset of Unity.Here it is:
var class01 = false; var asset : TextAsset; var textFieldString = "text field"; function OnGUI(){ if(GUI.Button(new Rect(80,10,200,40), "CAPTAIN")){ class01 = !class01; } if(class01){ GUI.Box(new Rect(80,100,200,200), asset.text); GUI.Button(new Rect(121, 250, 120, 30), "Create"); textFieldString = GUI.TextField (Rect (130, 120, 100, 30), textFieldString); } }
Actually how am i going to use those two scripts you wrote? Should i create the GUI buttons and apply them there? Apply them on the player perhaps?
You should do the UI as you normally would and access the list, do keep in $$anonymous$$d this was c#, but easy to port to unityscript
I was just giving an example of a setup.