Пример #1
0
        private void btn_changeWeapon(object sender, EventArgs e)
        {
            // get all the checked characters and add them to a list
            List <Character> checkedList = new List <Character>();

            for (int i = 0; i < checkedListBox2.CheckedItems.Count; i++)
            {
                for (int j = 0; j < characterList.Count; j++)
                {
                    if (characterList[j].getName() == (String)checkedListBox2.CheckedItems[i])
                    {
                        checkedList.Add(characterList[j]);
                    }
                }
            }

            //get the selected weapon from the check boxes and loop through the checked characters and set there new weapons
            IWeapon newWeapon = null;

            if (rdSword.Checked == true)
            {
                newWeapon = new WeaponSword();
            }
            else if (rdKnife.Checked == true)
            {
                newWeapon = new WeaponKnife();
            }
            else if (rdBow.Checked == true)
            {
                newWeapon = new WeaponBow();
            }
            else
            {
                MessageBox.Show("Please choose a weapon");
            }


            if (newWeapon != null)
            {
                for (int i = 0; i < checkedList.Count; i++)
                {
                    checkedList[i].setWeapon(newWeapon);
                }
            }
        }
Пример #2
0
        private void btn_changeWeapon(object sender, EventArgs e)
        {
            // get all the checked characters and add them to a list
            List<Character> checkedList = new List<Character>();

            for (int i = 0; i < checkedListBox2.CheckedItems.Count; i++)
            {
                for (int j = 0; j < characterList.Count; j++)
                {
                    if (characterList[j].getName() == (String)checkedListBox2.CheckedItems[i])
                    {
                        checkedList.Add(characterList[j]);
                    }
                }
            }

            //get the selected weapon from the check boxes and loop through the checked characters and set there new weapons
            IWeapon newWeapon = null;

            if (rdSword.Checked == true)
            {
                newWeapon = new WeaponSword();
            }
            else if (rdKnife.Checked == true)
            {
                newWeapon = new WeaponKnife();
            }
            else if (rdBow.Checked == true)
            {
                newWeapon = new WeaponBow();
            }
            else
                MessageBox.Show("Please choose a weapon");

            if (newWeapon != null)
            {
                for (int i = 0; i < checkedList.Count; i++)
                {
                    checkedList[i].setWeapon(newWeapon);
                }
            }
        }
Пример #3
0
 public King(String name, ListBox listbox)
     : base(name, listbox)
 {
     weapon = new WeaponSword();
 }
Пример #4
0
 public King(String name, ListBox listbox)
     : base(name, listbox)
 {
     weapon = new WeaponSword();
 }