- Home /
Saving skill allocations for characters
Hi guys, I'm stuck here trying to figure out if there's an efficient way to save skill allocations.
My situation is, I have 5 characters, and 5 job classes which are interchangeable between the characters. Each job has their own set of skills.
This is the best that I could muster up.
public string char;
public string job;
// job 1
public bool crush; // if equipped, gets true
public bool parry; // if equipped, gets true
public bool slam; // if equipped, gets true
// job 2
public bool magic; // if equipped, gets true
public bool evadeUp; // if equipped, gets true
void SaveSkill ()
{
if (char == "FirstChar" && job == "Warrior")
{
if (crush == true)
PlayerPrefs.setInt("FirstcharWarriorCrush", 1);
}
}
This means I have to go through all characters paired up with each job and its skills. I'll probably need to write like a hundred of these PlayerPrefs...
Any efficient method here? Please do tell.
Thanks!
Answer by YoungDeveloper · Jan 06, 2014 at 10:37 AM
You could create one class which would represent what is job itself, with all possible variations what is possible.
//C#
[System.Serializable]
public class Job{
public string name;
public bool crush;
public bool parry;
public bool slam;
public bool magic;
public bool evadeUp;
}
public Job[] allJobs;
Now, in inspector, you can create max job amount itself, and for each set what exactly you want.
oh.. cool! but how do i save this type of Job[] array? or recall it
i mean, how do i recall it from another scene file.
because they're equipped from one scene, and called up in another