Exemplo n.º 1
0
        static CareerJsonReader()
        {
            Assembly     assembly = Assembly.GetExecutingAssembly();
            StreamReader sr       = new StreamReader(assembly.GetManifestResourceStream("WFRP_NPC_Creator.Data.careers.json"));

            ClassList = JsonConvert.DeserializeObject(sr.ReadToEnd());
            sr.Close();


            CareerClass currentClass;
            CareerPath  currentPath;
            Career      currentTier;

            foreach (dynamic CareerClass in ClassList.Classes)
            {
                currentClass = new CareerClass(CareerClass.Name);
                foreach (dynamic career in CareerClass.First)
                {
                    currentPath = new CareerPath(career.Name);

                    int           tierCounter = 1;
                    List <string> skillList   = new List <string>();
                    List <string> trappings   = new List <string>();
                    foreach (dynamic tier in career.Value["Tiers"])
                    {
                        try
                        {
                            string            name       = tier["Name"];
                            List <string>     talentList = new List <string>();
                            Characteristics   c          = Characteristics.WS;
                            Characteristics[] characteristicAvailable = new Characteristics[tierCounter + 2];
                            int counter = 0;
                            foreach (dynamic characteristic in career.Value["Attributes"])
                            {
                                if (characteristic.Value != 0 && characteristic.Value <= tierCounter)
                                {
                                    characteristicAvailable[counter] = c;
                                    counter++;
                                }
                                c++;
                            }

                            foreach (dynamic skill in tier["Skills"])
                            {
                                skillList.Add(skill.Value);
                            }

                            foreach (dynamic talent in tier["Talents"])
                            {
                                talentList.Add(talent.Value);
                            }

                            foreach (dynamic trapping in tier["Trappings"])
                            {
                                trappings.Add(trapping.Value);
                            }
                            currentTier = new Career(name, tierCounter, characteristicAvailable, skillList.ToArray(), talentList.ToArray(), trappings.ToArray());
                            currentPath.AddTier(currentTier);
                            tierCounter++;
                        }
                        catch (Exception e)
                        {
                        }
                    }
                    currentClass.AddCareerPath(currentPath);
                }
                Career.ClassList.Add(currentClass);
            }
        }
Exemplo n.º 2
0
 public void AddCareerPath(CareerPath path)
 {
     CareerPaths.Add(path);
 }