Basically I created this skill class:
public class skill
{
public int level { get; set; } //Level of the skill (average of sub-skills' levels)
public int arrayCount { get; set; } //Number of skill/levels in the below arrays
public string[] sub_skills { get; set; } //Names of sub-skills ([0] connect's to levels' [0], etc.)
public int[] sub_levels { get; set; } //Levels of sub-skills ([0] connect's to names' [0], etc.)
void set(int l, int a, string[] sub_s, int[] sub_l)
{
this.level = l; //Sets the skill's level to the input'd l value
this.arrayCount = a; //Sets the skill's array count to the input'd a value
for (int i = 0; i < arrayCount; i++) //For loop to assign each value in both arrays
{
this.sub_skills[i] = sub_s[i]; //Assigns each input'd sub_s array value to each sub_skills value
this.sub_levels[i] = sub_l[i]; //Assigns each input'd sub_l array value to each sub_levels value
}
}
}
Now I have created another class, player:
public class Player
{
public string name { get; set; } //Name of Player
public int level { get; set; } //Player's combat level (average of combat-related skills' levels)
//Start Thievery skill block
string[] thief_s = { "lockpicking", "looting", "pickpocketing", "sneaking" }; //Array for thievery's sub-skill names
int[] thief_i = { 1, 1, 1, 1 }; //Array for thievery's sub-levels
skill thievery = new skill(); //Creates the skill of Thievery (stealing items / passing unnoticed)
//Start Melee skill block
skill melee = new skill(); //Creates the skill of Melee (close-range, strong combat)
//Start Archery skill block
skill archery = new skill(); //Creates the skill of Archery (long-range, weak combat)
//Start Magicka skill block
skill magicka = new skill(); //Creates the skill of Magicka (medium-range, medium combat)
//Start Craftship skill block
skill craftship = new skill(); //Creates the skill of Craftship (retreivement then creation of items from materials)
}
How can I use the set() method from the skill class inside the player class, for a specific skill created inside the player class? For example you can see how I have the skill thievery created there, already with its arrays for it's sub-level's names and levels (variables in the skill class). How can I access thievery's set() function and also use the arrays in it to set thievery's variables? I've tried the line thievery.set(// insertvarshere) but my IDE keeps throwing errors. (I'm using Microsoft Visual Studio Ultimate 2010)
EDIT: Thanks everyone. For some reason setting the set() function to public didn't change anything. When I call thievery.set() my IDE throws red lines under thievery. I'm going to take Charles advice and make the sub-skills skills, and then, if it's possible, apply some sort of tag to them to mark them as part of the major skill. Is that possible, or must I create my own class/function etc. for a tag?
void set(int l, int a, string[] sub_s, int[] sub_l)topublic void set(int l, int a, string[] sub_s, int[] sub_l). Is that the problem ?settopublic.Skillthat also includes the name of the skill, that would make a lot more sense