Пример #1
0
        public void load(string CharFile)
        {
            IniFile newFile = new IniFile("../../" + CharFile + ".char");

            //Console.WriteLine("loading character " + CharFile);
            //string charName = Path.GetFileNameWithoutExtension(newFile.path);

            Name     = newFile.IniReadValue(CharFile, "name");
            team     = newFile.IniReadValue(CharFile, "team");
            attack   = float.Parse(newFile.IniReadValue(CharFile, "attack"));
            accuracy = float.Parse(newFile.IniReadValue(CharFile, "accuracy"));
            spirit   = float.Parse(newFile.IniReadValue(CharFile, "spirit"));
            defense  = float.Parse(newFile.IniReadValue(CharFile, "defense"));
            evasion  = float.Parse(newFile.IniReadValue(CharFile, "evasion"));
            will     = float.Parse(newFile.IniReadValue(CharFile, "will"));

            speed   = float.Parse(newFile.IniReadValue(CharFile, "speed"));
            health  = float.Parse(newFile.IniReadValue(CharFile, "health"));
            stamina = float.Parse(newFile.IniReadValue(CharFile, "stamina"));

            resistances = new List <KeyValuePair <string, int> >();

            resistances.Add(new KeyValuePair <string, int>(
                                "fire", Convert.ToInt32(newFile.IniReadValue(CharFile, "resistFire"))));
            resistances.Add(new KeyValuePair <string, int>(
                                "ice", Convert.ToInt32(newFile.IniReadValue(CharFile, "resistIce"))));
            resistances.Add(new KeyValuePair <string, int>(
                                "water", Convert.ToInt32(newFile.IniReadValue(CharFile, "resistWater"))));
            resistances.Add(new KeyValuePair <string, int>(
                                "earth", Convert.ToInt32(newFile.IniReadValue(CharFile, "resistEarth"))));
            resistances.Add(new KeyValuePair <string, int>(
                                "wind", Convert.ToInt32(newFile.IniReadValue(CharFile, "resistWind"))));
            resistances.Add(new KeyValuePair <string, int>(
                                "electric", Convert.ToInt32(newFile.IniReadValue(CharFile, "resistElectric"))));
            resistances.Add(new KeyValuePair <string, int>(
                                "poison", Convert.ToInt32(newFile.IniReadValue(CharFile, "resistPoison"))));
            resistances.Add(new KeyValuePair <string, int>(
                                "dark", Convert.ToInt32(newFile.IniReadValue(CharFile, "resistDark"))));
            resistances.Add(new KeyValuePair <string, int>(
                                "light", Convert.ToInt32(newFile.IniReadValue(CharFile, "resistLight"))));
            resistances.Add(new KeyValuePair <string, int>(
                                "piercing", Convert.ToInt32(newFile.IniReadValue(CharFile, "resistPiercing"))));
            resistances.Add(new KeyValuePair <string, int>(
                                "blunt", Convert.ToInt32(newFile.IniReadValue(CharFile, "resistBlunt"))));
            resistances.Add(new KeyValuePair <string, int>(
                                "slashing", Convert.ToInt32(newFile.IniReadValue(CharFile, "resistSlashing"))));

            char[] seperator = new char[] { ',' };

            skills = new List <Skill>();
            string skillsList = newFile.IniReadValue(CharFile, "skills");

            if (skillsList.Length > 1)
            {
                string[] newSkills = skillsList.Split(seperator, StringSplitOptions.None);
                for (int s = 0; s < newSkills.Length; s++)
                {
                    Skill newSkill = new Skill(newSkills[s]);
                    //Console.WriteLine("Creating skill " + newSkill.Name);
                    skills.Add(newSkill);
                }
            }


            intrinsics = new List <Status>();
            string intrinsicList = newFile.IniReadValue(CharFile, "intrinsics");

            if (intrinsicList.Length > 1)
            {
                string[] newIntrinsic = intrinsicList.Split(seperator, StringSplitOptions.None);
                for (int n = 0; n < newIntrinsic.Length; n++)
                {
                    //intrinsics.Add(new Status(this,newIntrinsic[n]));
                    //addStatus(newIntrinsic[n]);
                }
            }


            statuses = new List <Status>();
            string status = newFile.IniReadValue(CharFile, "status");

            if (status.Length > 1)
            {
                string[] newStatuses = status.Split(seperator, StringSplitOptions.None);
                for (int t = 0; t < newStatuses.Length; t++)
                {
                    Status newStatus = new Status(this, newStatuses[t]);
                    statuses.Add(newStatus);
                }
            }

            equipment = new List <string>();
            string equips = newFile.IniReadValue(CharFile, "equipment");

            string[] newEquips = equips.Split(seperator, StringSplitOptions.None);
            for (int e = 0; e < newEquips.Length; e++)
            {
                equipment.Add(newEquips[e]);
            }

            weapons = new List <string>();
            string weapon = newFile.IniReadValue(CharFile, "weapons");

            string[] newWeapon = weapon.Split(seperator, StringSplitOptions.None);
            for (int w = 0; w < newWeapon.Length; w++)
            {
                weapons.Add(newWeapon[w]);
            }

            inventory = new List <string>();
            string items = newFile.IniReadValue(CharFile, "inventory");

            string[] newItems = items.Split(seperator, StringSplitOptions.None);
            for (int i = 0; i < newItems.Length; i++)
            {
                inventory.Add(newItems[i]);
            }

            checkNPC();
            setStats();
        }