예제 #1
0
    public void Open(int id, string type, int length, string route, int prizePool)
    {
        Race newRace = RaceFactory.GetRace(type, length, route, prizePool);

        if (newRace != null)
        {
            races.Add(id, newRace);
        }
    }
        private void Bonus_2_Combo_Box_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (Bonus_1_Combo_Box.SelectedIndex == Bonus_2_Combo_Box.SelectedIndex)
            {
                ContextInfoTextBlock.Text       = "You can't have two of the same bonuses, sorry!";
                Bonus_1_Combo_Box.SelectedIndex = 0;
                Bonus_2_Combo_Box.SelectedIndex = 1;
            }

            foreach (Label label in BonusGrid1.Children)
            {
                label.Content = null;
            }

            if (factory != null && CharContainer.race != null)
            {
                factory            = ConvertChoicesToRacialBonus();
                CharContainer.race = factory.GetRace();
                ModifyBonusBoxes();
            }
        }
        private void Bonus_1_Combo_Box_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ContextInfoTextBlock.Text = "As a half elf, you get to select your racial bonuses! Choose from one of the 5. Note that you can't stack bonuses i.e. you can't select strength twice.";

            if (Bonus_1_Combo_Box.SelectedIndex == Bonus_2_Combo_Box.SelectedIndex)
            {
                ContextInfoTextBlock.Text       = "You can't have two of the same bonuses, sorry!";
                Bonus_1_Combo_Box.SelectedIndex = 0;
                Bonus_2_Combo_Box.SelectedIndex = 1;
            }


            foreach (Label label in BonusGrid1.Children)
            {
                label.Content = null;
            }

            if (factory != null && CharContainer.race != null)
            {
                factory            = ConvertChoicesToRacialBonus();
                CharContainer.race = factory.GetRace();
                ModifyBonusBoxes();
            }
        }
        private void RaceListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Racial_Traits_Listbox.Items.Clear();



            //Cleaning up the bonus boxes if the race is changed.
            foreach (Label label in BonusGrid1.Children)
            {
                label.Content = null;
            }


            //This switch catches whatever race the user has selected, and assigns factory with correct type of factory. It then uses that factory to assign CharContainer a race.
            switch (RaceListBox.SelectedItem.ToString())
            {
            case "Dwarf":
                Bonus_1_Combo_Box.Visibility = Visibility.Hidden;
                Bonus_2_Combo_Box.Visibility = Visibility.Hidden;

                CharContainer.RaceName = "Dwarf";
                //Using the factory method to set the race for our dwarf. Same will apply below
                factory            = new DwarfFactory();
                CharContainer.race = factory.GetRace();
                ModifyBonusBoxes();
                break;

            case "Elf":
                Bonus_1_Combo_Box.Visibility = Visibility.Hidden;
                Bonus_2_Combo_Box.Visibility = Visibility.Hidden;
                CharContainer.RaceName       = "Elf";
                factory            = new ElfFactory();
                CharContainer.race = factory.GetRace();
                ModifyBonusBoxes();
                break;

            case "Half Elf":
                Bonus_1_Combo_Box.Visibility = Visibility.Visible;
                Bonus_2_Combo_Box.Visibility = Visibility.Visible;
                CharContainer.RaceName       = "Half Elf";

                factory = ConvertChoicesToRacialBonus();

                CharContainer.race = factory.GetRace();
                ModifyBonusBoxes();
                //return new HalfElfFactory();

                break;

            case "Dragonborn":
                Bonus_1_Combo_Box.Visibility = Visibility.Hidden;
                Bonus_2_Combo_Box.Visibility = Visibility.Hidden;
                CharContainer.RaceName       = "Dragonborn";
                factory            = new DragonBornFactory();
                CharContainer.race = factory.GetRace();
                ModifyBonusBoxes();
                break;

            case "Gnome":
                Bonus_1_Combo_Box.Visibility = Visibility.Hidden;
                Bonus_2_Combo_Box.Visibility = Visibility.Hidden;
                CharContainer.RaceName       = "Gnome";
                factory            = new GnomeFactory();
                CharContainer.race = factory.GetRace();
                ModifyBonusBoxes();
                break;

            case "Half Orc":
                Bonus_1_Combo_Box.Visibility = Visibility.Hidden;
                Bonus_2_Combo_Box.Visibility = Visibility.Hidden;
                CharContainer.RaceName       = "Half Orc";
                factory            = new HalfOrcFactory();
                CharContainer.race = factory.GetRace();
                ModifyBonusBoxes();
                break;

            case "Human":
                Bonus_1_Combo_Box.Visibility = Visibility.Hidden;
                Bonus_2_Combo_Box.Visibility = Visibility.Hidden;
                CharContainer.RaceName       = "Human";
                factory            = new HumanFactory();
                CharContainer.race = factory.GetRace();
                ModifyBonusBoxes();
                break;

            case "Tiefling":
                Bonus_1_Combo_Box.Visibility = Visibility.Hidden;
                Bonus_2_Combo_Box.Visibility = Visibility.Hidden;
                CharContainer.RaceName       = "Tiefling";
                factory            = new TieflingFactory();
                CharContainer.race = factory.GetRace();
                ModifyBonusBoxes();
                break;

            case "Halfling":
                Bonus_1_Combo_Box.Visibility = Visibility.Hidden;
                Bonus_2_Combo_Box.Visibility = Visibility.Hidden;
                CharContainer.RaceName       = "Halfling";
                factory            = new HalflingFactory();
                CharContainer.race = factory.GetRace();
                ModifyBonusBoxes();
                break;

            default:
                break;
            }

            if (CharContainer.race != null)
            {
                ContextInfoTextBlock.Text = CharContainer.race.RaceDescription;
            }

            //Filling up the racial traits LIstbox
            foreach (var trait in CharContainer.race.racialTraits)
            {
                Racial_Traits_Listbox.Items.Add(trait.Item1);
            }

            foreach (var image in container.raceImages)
            {
                //Go through the Tuple list that was read in from our database, if the name of the player's race matches the name of the race image, then set it. also set the picture box so that the user knows it has changed.
                if (CharContainer.RaceName == image.Item1)
                {
                    RacePicture.Image             = image.Item2;
                    CharContainer.characterAvatar = image.Item2;
                }
            }

            CharContainer.SetModifiers();
            CharContainer.UpdateArmorClass();
            Armor_Class_Text_Box.Text = CharContainer.characterClass.ArmorClass.ToString();
        }