Ok… I have this “character” class for an RPG style game I’m building… What I want to be able to do is to get the players abilities by using Character.Ability.Scores.Str
. This is what I’ve somehow stumbled upon, as this is my first class attempt, and I don’t know IF it’s possible and how I would do it if it is…
Here’s my script so far…
“StatDataBase.GetBaseStats” is just getting an array of ability scores from the class and race
public class Character {
// Get a brand new level 1 character
public Character(string Race, string Class) {
int[] NewScores = StatDataBase.GetBaseStats(Race, Class);
Ability.Scores.Str = NewScores[0];
Ability.Scores.Dex = NewScores[1];
Ability.Scores.Con = NewScores[2];
Ability.Scores.Wis = NewScores[3];
Ability.Scores.Int = NewScores[4];
Ability.Scores.Cha = NewScores[5];
}
// Get a character with ability modifications
public Character(string Race, string Class, int[] Modifiers) {
Stats = StatDataBase.GetBaseStats(Race, Class);
int Selection = 0;
foreach (int item in Modifiers) {
Stats[Selection] += Modifiers[Selection];
Selection++;
}
}
// can't access the variables in here when using 'Character.Ability.Scores.Str"
public class Ability {
public class Scores {
static public int Str;
static public int Dex;
static public int Con;
static public int Wis;
static public int Int;
static public int Cha;
}
}
}
Please try to explain any and all help as I know nothing about creating Classes!