Пример #1
0
 public HeroForm()
 {
     InitializeComponent();
     newHero = new SuperHero();
 }
        }     // end of method

        // Create hero Button
        private void createHeroBtn_Click(object sender, EventArgs e)
        {
            // Variables used to pass info to second form
            string    name             = herosNameTextBox.Text;
            ArrayList skills           = new ArrayList();
            string    townOfOrigin     = OriginListBox.SelectedItem.ToString();
            string    travelBy         = "";
            decimal   yearsExperience  = yearsExperienceNumberSpinner.Value;
            string    capeColor        = capeColorDialogBox.Color.ToString();
            int       villainPotential = villainPotentialTrackBar.Value;
            string    portraitFile     = portraitPictureBox.Name;

            // Skills added when button is clicked
            if (superStrengthCheckBox.CheckState == CheckState.Checked)
            {
                skills.Add("Super Strength");
            } // end of if
            if (flightCheckBox.CheckState == CheckState.Checked)
            {
                skills.Add("Flight");
            }// end of if
            if (xRayVisionCheckBox.CheckState == CheckState.Checked)
            {
                skills.Add("X-Ray Vision");
            }// end of if
            if (invisibilityCheckBox.CheckState == CheckState.Checked)
            {
                skills.Add("Invisibility");
            }// end of if
            if (healingCheckBox.CheckState == CheckState.Checked)
            {
                skills.Add("Healing");
            }// end of if
            if (telekinesisCheckBox.CheckState == CheckState.Checked)
            {
                skills.Add("Telekinesis");
            }// end of if
            if (ShapeShifterCheckBox.CheckState == CheckState.Checked)
            {
                skills.Add("Shape Shifting");
            }// end of if
            if (ElementalCheckBox.CheckState == CheckState.Checked)
            {
                skills.Add("Elemental Control");
            }// end of if
            if (MindControlCheckBox.CheckState == CheckState.Checked)
            {
                skills.Add("Mind Control");
            }// end of if
            if (MultiverseCheckBox.CheckState == CheckState.Checked)
            {
                skills.Add("Multiversal Control");
            }// end of if
            if (underWaterControlCheckBox.CheckState == CheckState.Checked)
            {
                skills.Add("UnderWater Control");
            }// end of if
            if (SuperSpeedCheckBox.CheckState == CheckState.Checked)
            {
                skills.Add("Super Speed");
            }// end of if

            //Dates are uploaded when user adds hero
            DateTime[] importantDates = new DateTime[3] {
                birthdayDatePicker.Value, superPowerDiscoveryDatePicker.Value, fatefulDayDatePicker.Value
            };

            // Used to upload travel by methods when hero is added
            if (jetpackRadioBtn.Checked)
            {
                travelBy = "Jetpack";
            }// end of if
            if (HelicopterRadioBtn.Checked)
            {
                travelBy = "Helicopter";
            }// end of if
            if (teleportRadioBtn.Checked)
            {
                travelBy = "Teleport";
            }// end of if
            if (carRadioBtn.Checked)
            {
                travelBy = "Car";
            }// end of if

            // Sets the stats to the hero when hero is added
            int[] stats = new int[3] {
                speedHScrollBar.Value, staminaHScrollBar.Value, strengthHScrollBar.Value
            };

            // Passes hero information when button is clicked
            myName = herosNameTextBox.Text;
            SuperHero superHero = new SuperHero(name, skills, townOfOrigin, travelBy, importantDates, yearsExperience, capeColor, villainPotential, stats, portraitFile);

            SuperHeroList.listOfHeros.Add(superHero);
            Form2 f2 = new Form2(myName);

            f2.Show();
            this.Hide();
        } // end of method