基本的に私はこのskill
クラスを作成しました:
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
}
}
}
今、私は別のクラスを作成しました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)
}
クラス内で作成された特定のスキルに対して、クラス内でクラスのset()
メソッドを使用するにはどうすればよいですか? たとえば、サブレベルの名前とレベル (クラス内の変数) の配列を使用して、スキルを作成した方法を確認できます。の関数にアクセスし、その中の配列を使用しての変数を設定するにはどうすればよいですか? この行を試しましたが、IDE がエラーをスローし続けます。(Microsoft Visual Studio Ultimate 2010 を使用しています)skill
player
player
thievery
skill
thievery
set()
thievery
thievery.set(// insertvarshere)
編集:みんなありがとう。何らかの理由でset()
関数を public に設定しても何も変わりませんでした。thievery.set()
IDEを呼び出すと、下に赤い線が表示されthievery
ます。チャールズのアドバイスを受けてサブスキルのスキルを作成し、可能であればそれらに何らかのタグを付けて、メジャースキルの一部としてマークします. それは可能ですか、それともタグ用に独自のクラス/関数などを作成する必要がありますか?