Example #1
0
        public bool InsertFighter(FightActor fighter, int index)
        {
            if (index > Fighters.Count)
            {
                return(false);
            }

            Fighters.Insert(index, fighter);

            if (index <= Index)
            {
                Index++;
            }

            return(true);
        }
Example #2
0
        public void AddNewHero(object sender, RoutedEventArgs e)
        {
            Fighter NewHero = new Ghoblin();
            string  Race    = AddHeroWindow.Races.SelectedItem.ToString();

            try
            {
                switch (Race)
                {
                case "Берсерк":
                    NewHero = new Berzerk(AddHeroWindow.HeroName.Text, "Берсерк");
                    break;

                case "Эльф":
                    NewHero = new Elph(AddHeroWindow.HeroName.Text, "Эльф");
                    break;

                case "Гоблин":
                    NewHero = new Ghoblin(AddHeroWindow.HeroName.Text, "Гоблин");
                    break;

                default: throw new Exception();
                }
                NewHero.Username = CurrentUser.Username;
                Fighters.Insert(0, NewHero);
                SelectedFighter = Fighters[0];
                using (UnitOfWork T = new UnitOfWork())
                {
                    T.GetFighters().Add(NewHero);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            AddHeroWindow.Close();
        }