コード例 #1
0
        private void lbxPremadeHeros_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            PreMadeHero selectedPreMadeHero = lbxPremadeHeroes.SelectedItem as PreMadeHero;



            int id = selectedPreMadeHero.Id;

            string heroImg     = selectedPreMadeHero.HeroImage;
            string description = selectedPreMadeHero.Description;

            int selectedWeaponId = selectedPreMadeHero.Weapon_Id;
            var selectedSpellId  = selectedPreMadeHero.Spell_Id;

            var weaponsQuery = from ph in db.PreMadeHeroes
                               join w in db.Weapons on ph.Weapon_Id equals w.Id
                               where ph.Weapon_Id == selectedWeaponId
                               select w.Name;

            var spellsQuery = from ph in db.PreMadeHeroes
                              join s in db.Spells on ph.Spell_Id equals s.Id
                              where ph.Spell_Id == selectedSpellId
                              select s.Name;



            imgPremadeHero.Source             = new BitmapImage(new Uri(heroImg));
            txtblPremadeHeroDescription.Text  = description;
            lbxPremadeHeroWeapons.ItemsSource = weaponsQuery.ToList().Distinct();
            lbxPremadeHeroSpells.ItemsSource  = spellsQuery.ToList().Distinct();
        }
コード例 #2
0
        private void addPremadeHero_Click(object sender, RoutedEventArgs e)
        {
            //Add the Premade Hero
            PreMadeHero selectedHero = lbxPremadeHeroes.SelectedItem as PreMadeHero;

            try
            {
                if (selectedHero != null)
                {
                    //Adds teh hero and diplays their class image
                    switch (selectedHero.Class_Id)
                    {
                    case 1:
                        Hero PremadeBarbarian = new Hero(selectedHero.Name, int.Parse(selectedHero.AC), int.Parse(selectedHero.HP), Classes.Barbarian, int.Parse(selectedHero.Dex), selectedHero.Description, selectedHero.HeroImage);
                        combat.Add(PremadeBarbarian);
                        break;

                    case 2:
                        Hero PremadeBard = new Hero(selectedHero.Name, int.Parse(selectedHero.AC), int.Parse(selectedHero.HP), Classes.Bard, int.Parse(selectedHero.Dex), selectedHero.Description, selectedHero.HeroImage);
                        combat.Add(PremadeBard);
                        break;

                    case 3:
                        Hero PremadeCleric = new Hero(selectedHero.Name, int.Parse(selectedHero.AC), int.Parse(selectedHero.HP), Classes.Cleric, int.Parse(selectedHero.Dex), selectedHero.Description, selectedHero.HeroImage);
                        combat.Add(PremadeCleric);
                        break;

                    case 5:
                        Hero PremadeDruid = new Hero(selectedHero.Name, int.Parse(selectedHero.AC), int.Parse(selectedHero.HP), Classes.Druid, int.Parse(selectedHero.Dex), selectedHero.Description, selectedHero.HeroImage);
                        combat.Add(PremadeDruid);
                        break;

                    case 6:
                        Hero PremadeFighter = new Hero(selectedHero.Name, int.Parse(selectedHero.AC), int.Parse(selectedHero.HP), Classes.Figther, int.Parse(selectedHero.Dex), selectedHero.Description, selectedHero.HeroImage);
                        combat.Add(PremadeFighter);
                        break;

                    case 7:
                        Hero PremadeMonk = new Hero(selectedHero.Name, int.Parse(selectedHero.AC), int.Parse(selectedHero.HP), Classes.Monk, int.Parse(selectedHero.Dex), selectedHero.Description, selectedHero.HeroImage);
                        combat.Add(PremadeMonk);
                        break;

                    case 8:
                        Hero PremadePaladin = new Hero(selectedHero.Name, int.Parse(selectedHero.AC), int.Parse(selectedHero.HP), Classes.Paladin, int.Parse(selectedHero.Dex), selectedHero.Description, selectedHero.HeroImage);
                        combat.Add(PremadePaladin);
                        break;

                    case 9:
                        Hero PremadeRanger = new Hero(selectedHero.Name, int.Parse(selectedHero.AC), int.Parse(selectedHero.HP), Classes.Ranger, int.Parse(selectedHero.Dex), selectedHero.Description, selectedHero.HeroImage);
                        combat.Add(PremadeRanger);
                        break;

                    case 10:
                        Hero PremadeRouge = new Hero(selectedHero.Name, int.Parse(selectedHero.AC), int.Parse(selectedHero.HP), Classes.Rouge, int.Parse(selectedHero.Dex), selectedHero.Description, selectedHero.HeroImage);
                        combat.Add(PremadeRouge);
                        break;

                    case 11:
                        Hero PremadeSorcerer = new Hero(selectedHero.Name, int.Parse(selectedHero.AC), int.Parse(selectedHero.HP), Classes.Sorcerer, int.Parse(selectedHero.Dex), selectedHero.Description, selectedHero.HeroImage);
                        combat.Add(PremadeSorcerer);
                        break;

                    case 12:
                        Hero PremadeWarlock = new Hero(selectedHero.Name, int.Parse(selectedHero.AC), int.Parse(selectedHero.HP), Classes.Warlock, int.Parse(selectedHero.Dex), selectedHero.Description, selectedHero.HeroImage);
                        combat.Add(PremadeWarlock);
                        break;

                    case 13:
                        Hero PremadeWizard = new Hero(selectedHero.Name, int.Parse(selectedHero.AC), int.Parse(selectedHero.HP), Classes.Wizard, int.Parse(selectedHero.Dex), selectedHero.Description, selectedHero.HeroImage);
                        combat.Add(PremadeWizard);
                        break;
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("An error has occured", "Error");
                throw;
            }
            //Sort Combat listbox and refresh
            combat.Sort();
            combat.Reverse();
            RefreshScreen();
        }