Esempio n. 1
0
        public HeroBuild(string BuildName, Hero Hero)
        {
            m_BuildName = BuildName;
            m_Hero = Hero;

            for (int i = 0; i < 26; i++) m_Choices[i] = LevelChoice.Nothing;
        }
Esempio n. 2
0
        private void cbox_heroes_SelectedIndexChanged(object sender, EventArgs e)
        {
            string heroName = cbox_heroes.Items[cbox_heroes.SelectedIndex].ToString();

            selectedHero = HoNBP.getHeroByName(heroName);

            if (selectedHero != null)
            {
                pbox_hero.Load(selectedHero.Portrait());
            }
        }
Esempio n. 3
0
        public static void loadHeroesFromFile()
        {
            ArrayList xml_list = new ArrayList();
            Heroes = new Hashtable();
            Hero newHero;
            Skill[] heroSkills;

            string temp;
            string temp2;

            //Hero attributes:
            string heroName;
            string heroPortrait;

            HeroPrimaryAttr heroPrim;
            int heroInitialHP;
            int heroInitialMana;
            float heroInitialHPRegen;
            float heroInitialManaRegen;

            int heroIStr;
            int heroIAgi;
            int heroIInt;

            int heroMovS;
            float heroStrPerLevel;
            float heroAgiPerLevel;
            float heroIntPerLevel;

            float heroArmor;
            float heroMagicArmor;

            HeroAttackType heroAttackType;
            int heroMinDamage;
            int heroMaxDamage;
            int heroAttackRange;
            float heroBAT;

            //Loading xml list file
            try
            {
                XmlReader reader = XmlReader.Create("./data/heroes.xml");

                reader.ReadStartElement("HoNBuildPlanner");
                reader.ReadStartElement("HeroList");

                while (reader.IsStartElement("File"))
                {
                    xml_list.Add(reader.ReadElementString("File"));
                }

                reader.ReadEndElement();
                reader.ReadEndElement();
                reader.Close();
            }
            catch (Exception ex)
            {
                exceptionWindow ew = new exceptionWindow(ex.ToString());
                ew.ShowDialog();
            }

            //Parsing heroes xml files

            while (xml_list.Count > 0)
            {
                try
                {
                    XmlReader reader = XmlReader.Create("./data/" + xml_list[0].ToString());

                    reader.ReadStartElement("HoNBuildPlanner");

                    while (reader.IsStartElement("Hero"))
                    {
                        heroSkills = new Skill[4];

                        reader.ReadStartElement("Hero");

                        reader.ReadStartElement("Name");
                        heroName = reader.ReadString();
                        reader.ReadEndElement();

                        reader.ReadStartElement("PrimaryAttribute");
                        temp = reader.ReadString();
                        reader.ReadEndElement();

                        switch (temp)
                        {
                            case "Strength":
                                heroPrim = HeroPrimaryAttr.Strength;
                                break;
                            case "Agility":
                                heroPrim = HeroPrimaryAttr.Agility;
                                break;
                            case "Intelligence":
                                heroPrim = HeroPrimaryAttr.Intelligence;
                                break;
                            default:
                                heroPrim = HeroPrimaryAttr.Strength;
                                break;
                        }

                        reader.ReadStartElement("InitialHP");
                        heroInitialHP = int.Parse(reader.ReadString());
                        reader.ReadEndElement();

                        reader.ReadStartElement("InitialHPRegen");
                        heroInitialHPRegen = float.Parse(reader.ReadString());
                        reader.ReadEndElement();

                        reader.ReadStartElement("InitialMana");
                        heroInitialMana = int.Parse(reader.ReadString());
                        reader.ReadEndElement();

                        reader.ReadStartElement("InitialManaRegen");
                        heroInitialManaRegen = float.Parse(reader.ReadString());
                        reader.ReadEndElement();

                        reader.ReadStartElement("InitialAttirbutes");

                        reader.ReadStartElement("Strength");
                        heroIStr = int.Parse(reader.ReadString());
                        reader.ReadEndElement();

                        reader.ReadStartElement("Agility");
                        heroIAgi = int.Parse(reader.ReadString());
                        reader.ReadEndElement();

                        reader.ReadStartElement("Intelligence");
                        heroIInt = int.Parse(reader.ReadString());
                        reader.ReadEndElement();

                        reader.ReadEndElement();

                        reader.ReadStartElement("MovementSpeed");
                        heroMovS = int.Parse(reader.ReadString());
                        reader.ReadEndElement();

                        reader.ReadStartElement("PerLevel");

                        reader.ReadStartElement("Strength");
                        heroStrPerLevel = float.Parse(reader.ReadString());
                        reader.ReadEndElement();

                        reader.ReadStartElement("Agility");
                        heroAgiPerLevel = float.Parse(reader.ReadString());
                        reader.ReadEndElement();

                        reader.ReadStartElement("Intelligence");
                        heroIntPerLevel = float.Parse(reader.ReadString());
                        reader.ReadEndElement();

                        reader.ReadEndElement();

                        reader.ReadStartElement("Armor");
                        heroArmor = float.Parse(reader.ReadString());
                        reader.ReadEndElement();

                        reader.ReadStartElement("MagicArmor");
                        heroMagicArmor = float.Parse(reader.ReadString());
                        reader.ReadEndElement();

                        reader.ReadStartElement("AttackType");
                        temp = reader.ReadString();
                        reader.ReadEndElement();

                        switch (temp)
                        {
                            case "Melee":
                                heroAttackType = HeroAttackType.Melee;
                                break;
                            case "Ranged":
                                heroAttackType = HeroAttackType.Ranged;
                                break;
                            default:
                                heroAttackType = HeroAttackType.Melee;
                                break;
                        }

                        reader.ReadStartElement("MinDamage");
                        heroMinDamage = int.Parse(reader.ReadString());
                        reader.ReadEndElement();

                        reader.ReadStartElement("MaxDamage");
                        heroMaxDamage = int.Parse(reader.ReadString());
                        reader.ReadEndElement();

                        reader.ReadStartElement("Range");
                        heroAttackRange = int.Parse(reader.ReadString());
                        reader.ReadEndElement();

                        reader.ReadStartElement("BAT");
                        heroBAT = float.Parse(reader.ReadString());
                        reader.ReadEndElement();

                        reader.ReadStartElement("Skills");

                        for (int i = 0; i < 4; i++)
                        {
                            reader.ReadStartElement("Skill");

                            reader.ReadStartElement("Name");
                            temp = reader.ReadString();
                            reader.ReadEndElement();

                            reader.ReadStartElement("Lore");
                            temp2 = reader.ReadString();
                            reader.ReadEndElement();
                            heroSkills[i] = new Skill(temp, temp2);

                            reader.ReadStartElement("image");
                            temp = reader.ReadString();
                            reader.ReadEndElement();

                            heroSkills[i].setImage(temp);

                            reader.ReadEndElement();
                        }

                        reader.ReadEndElement();

                        reader.ReadStartElement("portrait");
                        heroPortrait = reader.ReadString();
                        reader.ReadEndElement();

                        reader.ReadEndElement();

                        newHero = new Hero(heroName, heroPrim, heroIStr, heroIAgi, heroIInt, heroInitialHP, heroInitialHPRegen,
                                            heroInitialMana, heroInitialManaRegen, heroMovS, heroStrPerLevel, heroAgiPerLevel,
                                            heroIntPerLevel, heroArmor, heroMagicArmor, heroAttackType,
                                            heroMinDamage, heroMaxDamage, heroAttackRange, heroBAT,
                                            heroSkills[0], heroSkills[1], heroSkills[2], heroSkills[3]);

                        newHero.Portrait(heroPortrait);

                        Heroes.Add(heroName, newHero);
                    }

                    reader.ReadEndElement();
                    reader.Close();
                }
                catch (Exception ex)
                {
                    exceptionWindow ew = new exceptionWindow(ex.ToString());
                    ew.ShowDialog();
                }

                xml_list.RemoveAt(0);
            }

            return;
        }