Hi guys, I’m fumbling my way through an RPG… I’ve been hesitant to ask this on here as its kinda big.
Question:
I have a script that creates a class for Sex. In this Sex are strings to call names (his, her, she, him, male, female) and designate the character’s gender. Problem is, I can only seem to access these Male and Female Sex classes if I put them in an array and reference their count in the array. See my code below:
using System.Collections;
public static class SexData {
public static Sex NoGender;
public static Sex Male;
public static Sex Female;
public static Sex[] sexList;
public static int maleIndex = 1;
public class Sex {
public string name;
public string possesiveName;
public string thirdPersonName;
public string youngName;
public string grownName;
public Vector3 sexScale;
public int[] hairIndexes;
}
static SexData(){
Sex NoGender = new Sex();
NoGender.name = "No Gender";
Sex Male = new Sex();
Male.name = "Male";
Male.possesiveName = "his";
Male.thirdPersonName = "he";
Male.youngName = "boy";
Male.grownName = "man";
Male.sexScale = new Vector3(1, 1, 1);
Sex Female = new Sex();
Female.name = "Female";
Female.possesiveName = "her";
Female.thirdPersonName = "she";
Female.youngName = "girl";
Female.grownName = "woman";
Female.sexScale = new Vector3(.8f, .9f, .8f);
sexList = new Sex[] {NoGender, Male, Female};
}
}
To access these values outside the script, I cant just do “characterSex = SexData.Male”, I need to do “characterSex = SexData.sexList[1]”
I cant believe this is the proper way to do what I’m doing, but it works for now. Should I be using a struct? Is this a case of value type vs reference type?
Thanks all!