Exemplo n.º 1
0
        private void Submit_ButtonClick(object sender, RoutedEventArgs e)
        {
            bool isNumeric = int.TryParse(tbHealthField.Text, out int health);

            if (String.IsNullOrWhiteSpace(tbNameField.Text) || String.IsNullOrWhiteSpace(tbHealthField.Text) || !isNumeric)
            {
                tb_SubmitErrorMessage.Text = "Please make sure that all entered values are valid";
            }
            else
            {
                string           name       = tbNameField.Text;
                DamageType       type       = (DamageType)cbTypeList_window.SelectedItem;
                int              heroId     = GameContainer.AddHeroTarget(name, health, type);
                CharacterAccount heroTarget = GameContainer.ActiveGame.AllTargets[heroId];
                MainWindow.AllTargets.Add(heroTarget);
                MainWindow.HeroTargets.Add(heroTarget);
                this.Close();
            }
        }