private void addRemoveSkillBtn_Click(object sender, EventArgs e) { if (comboType.Text != "None") { try { FrmSkillsAdder skillsAdder = new FrmSkillsAdder(skillNames, characterCreation.TotalTierPoints, characterCreation, comboType.Text); //Sends the weight & height for the checkRequirement. characterCreation.WeightTotal = int.Parse(txtWeight.Text); characterCreation.HeightTotal = int.Parse(txtHeightFt.Text); if (characterCreation.WeightTotal == 0 && characterCreation.HeightTotal == 0) throw new Exception("Make sure you entered a weight and a height!"); else if (characterCreation.HeightTotal == 0) throw new Exception("Make sure you entered a height!"); else if (characterCreation.WeightTotal == 0) throw new Exception("Make sure you entered a weight!"); if (skillsAdder.ShowDialog() == DialogResult.OK) { characterCreation.TotalTierPoints = skillsAdder.TotalTierPoints; lstSkillsPicked.Items.Clear(); lstSkillsPicked.Items.AddRange(skillsAdder.skillsAdded); //Stops the user from modifying stats when bonuses are applied to them. if (lstSkillsPicked.Items.Count > 0) { comboType.Enabled = false; panel1.Enabled = false; } else { comboType.Enabled = true; panel1.Enabled = true; } //Passes the skills so that their bonuses may be applied. skillNames = new string[lstSkillsPicked.Items.Count]; lstSkillsPicked.Items.CopyTo(skillNames, 0); characterCreation.skillBonusApplier(skillNames, comboType.Text, 0); //Sets the bonuses in the textboxes. bonusFromIntToTextBox(); } //Updates the characterCreation's dictionary when the DialogResult = Cancel. else if (skillNames != null) characterCreation.skillBonusApplier(skillNames, comboType.Text, 0); //Stops the Stat Points from being displayed as less than 0 when skills/type bonuses are added to //attributes. if (int.Parse(txtStatPoints.Text) < 0) txtStatPoints.Text = "0"; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else MessageBox.Show("Make sure you selected a type first.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); }
string[] skillNames = null; //Keeps track of the skills added. private void addRemoveSkillBtn_Click(object sender, EventArgs e) { if (comboType.Text != "None") { try { FrmSkillsAdder skillsAdder = new FrmSkillsAdder(skillNames, characterCreation.TotalTierPoints, characterCreation, comboType.Text); //Sends the weight & height for the checkRequirement. characterCreation.WeightTotal = int.Parse(txtWeight.Text); characterCreation.HeightTotal = int.Parse(txtHeightFt.Text); if (characterCreation.WeightTotal == 0 && characterCreation.HeightTotal == 0) { throw new Exception("Make sure you entered a weight and a height!"); } else if (characterCreation.HeightTotal == 0) { throw new Exception("Make sure you entered a height!"); } else if (characterCreation.WeightTotal == 0) { throw new Exception("Make sure you entered a weight!"); } if (skillsAdder.ShowDialog() == DialogResult.OK) { characterCreation.TotalTierPoints = skillsAdder.TotalTierPoints; lstSkillsPicked.Items.Clear(); lstSkillsPicked.Items.AddRange(skillsAdder.skillsAdded); //Stops the user from modifying stats when bonuses are applied to them. if (lstSkillsPicked.Items.Count > 0) { comboType.Enabled = false; panel1.Enabled = false; } else { comboType.Enabled = true; panel1.Enabled = true; } //Passes the skills so that their bonuses may be applied. skillNames = new string[lstSkillsPicked.Items.Count]; lstSkillsPicked.Items.CopyTo(skillNames, 0); characterCreation.skillBonusApplier(skillNames, comboType.Text, 0); //Sets the bonuses in the textboxes. bonusFromIntToTextBox(); } //Updates the characterCreation's dictionary when the DialogResult = Cancel. else if (skillNames != null) { characterCreation.skillBonusApplier(skillNames, comboType.Text, 0); } //Stops the Stat Points from being displayed as less than 0 when skills/type bonuses are added to //attributes. if (int.Parse(txtStatPoints.Text) < 0) { txtStatPoints.Text = "0"; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Make sure you selected a type first.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }