示例#1
0
 public Hero(Constitution constitution, Dress weapon, Dress headdress, Dress boots, Dress ring1, Dress ring2, Dress gloves, Dress leggings,
             Dress bodyArmor)
 {
     Parameters = new List <Parameters> {
         constitution, weapon, headdress, boots, ring1, ring2, gloves, leggings, bodyArmor
     };
     SetParameters();
 }
示例#2
0
        //public static Enum Translation(Enum firstEnum, Enum secondEnum, string strFforTranslation)
        //{
        //   return (firstEnum.)Enum.Parse(typeof(secondEnum), strFforTranslation, true)
        //}
        public static Constitution ChangeRaceAndCreate(Race race, string name)
        {
            Constitution newChar = new Constitution();

            switch (race)
            {
            case Race.Human:
                Human human = new Human(name);
                newChar = human;
                break;

            case Race.Elf:
                Elf elf = new Elf(name);
                newChar = elf;
                break;

            case Race.Gnome:
                Gnome gnome = new Gnome(name);
                newChar = gnome;
                break;

            case Race.Orc:
                Orc orc = new Orc(name);
                newChar = orc;
                break;

            case Race.Witcher:
                Witcher witcher = new Witcher(name);
                newChar = witcher;
                break;

            case Race.Elemental:
                Elemental elemental = new Elemental(name);
                newChar = elemental;
                break;

            default:
                MessageBox.Show("Некорректно указана раса.");
                break;
            }
            return(newChar);
        }
示例#3
0
        private void btnAddChar_Click(object sender, EventArgs e)
        {
            if (tBxName.Text == "")
            {
                MessageBox.Show("Не выбрано имя!");
                return;
            }
            Constitution newChar = Calculate.ChangeRaceAndCreate((Race)Enum.Parse(typeof(RaceInRussian), cBxRace.Text, true), tBxName.Text);

            foreach (Parameters constitution in FmMain.ListChar.Chars)
            {
                if (constitution.Name == newChar.Name)
                {
                    MessageBox.Show("Герой с таким именем уже в игре. Позовите другого героя!");
                    return;
                }
            }
            FmMain.ListChar.AddInChars(newChar);
            DAO.AddStringToFile(newChar.Name + "\t" + newChar.Race, Constants.CHARS_FILE_NAME);
            Close();
        }