Exemplo n.º 1
0
 public Queen(ListBox listBox, String name)
     : base(listBox, name)
 {
     this.Name = name;
     this.ListBox = listBox;
     weapon = new Bow();
 }
Exemplo n.º 2
0
        public void Character_CanChangeWeaponAtRunTime()
        {
            Character character = new King("Johnny");
            IWeaponBehaviour newWeapon = new Bow();

            character.Weapon = newWeapon;

            Assert.AreEqual(character.UseWeapon(), newWeapon.UseWeapon());
        }
        public static IWeaponBehaviour CreateWeapon(string name)
        {
            IWeaponBehaviour newWeapon;

            switch (name)
            {
            case "Sword":
                newWeapon = new Sword();
                break;

            case "Bow":
                newWeapon = new Bow();
                break;

            case "Dagger":
                newWeapon = new Dagger();
                break;

            default:
                newWeapon = null;
                break;
            }
            return(newWeapon);
        }
Exemplo n.º 4
0
 public Queen(ListBox BattleBox, string Name)
 {
     name = Name;
     weaponType = new Bow();
     battleBox = BattleBox;
 }
Exemplo n.º 5
0
        /**
         *  Change weapon button click handler
         */
        private void button1_Click(object sender, EventArgs e)
        {
            // Get the checked characters
            List<int> selectedCharacters = getCheckedItemsInCheckedListBox(weaponCheckedListBox);

            // check at least one character is selected
            if (selectedCharacters.Count > 0)
            {
                IWeaponBehaviour newWeapon = null;

                // Get the weapon type
                if (rdSword.Checked)
                    newWeapon = new Sword();
                else if (rdKnife.Checked)
                    newWeapon = new Knife();
                else if (rdBow.Checked)
                    newWeapon = new Bow();
                else
                    MessageBox.Show("Please select a new weapon for the character(s)");

                // If a weapon was selected, change the characters weapon type(s)
                if (newWeapon != null)
                {
                    foreach (int charaterIndex in selectedCharacters)
                    {
                        gameManager.ChangeCharactersWeapon(charaterIndex, newWeapon);
                    }

                    // Set change weapon radios back to the default of sword
                    rdSword.Checked = true;
                }
            }
            else
            {
                MessageBox.Show("Please select at least one character to change the weapon of");
            }
        }
Exemplo n.º 6
0
 // We have descended from our parent abstract class, Character.
 // We use : base to execute the base class' (Character's) code, and give her a weapon.
 public Queen(ListBox listBox, String myName) : base(listBox, myName)
 {
     Weapon = new Bow();
 }
 public Troll(string name) : base(name)
 {
     Weapon = new Bow();
 }
Exemplo n.º 8
0
 //Child of charater class, when instantiated a default weapon is set forht type of charater
 public Queen(String characterName)
     : base(characterName)
 {
     weapon = new Bow();
 }
Exemplo n.º 9
0
 //Child of charater class, when instantiated a default weapon is set forht type of charater
 public Troll(String characterName)
     : base(characterName)
 {
     weapon = new Bow();
 }
 //Constructor
 public Queen(string name) : base(name)
 {
     this.name = name;
     weapon    = new Bow();
 }
Exemplo n.º 11
0
 public Troll(String name)
     : base(name)
 {
     Weapon = new Bow();
 }
Exemplo n.º 12
0
 public Troll(ListBox listBox, String myName)
     : base(listBox, myName)
 {
     Weapon = new Bow();
 }
Exemplo n.º 13
0
 public Troll(string name)
     : base(name)
 {
     base.name = name;
     weapon = new Bow();
 }
Exemplo n.º 14
0
 public Queen(string name) : base(name)
 {
     weapon  = new Bow();
     declaim = "I am the powerful Queen!";
 }
Exemplo n.º 15
0
 public Queen(string name)
     : base(name)
 {
     base.name = name;
     weapon = new Bow();
 }
Exemplo n.º 16
0
 public Queen(string name)
     : base(name)
 {
     weapon = new Bow();
     declaim = "I am the powerful Queen!";
 }
Exemplo n.º 17
0
 public Queen(String name) : base(name)
 {
     Weapon = new Bow();
 }
Exemplo n.º 18
0
 // We have descended from our parent abstract class, Character.
 // We use : base to execute the base class' (Character's) code, and give her a weapon.
 public Queen(ListBox listBox, String myName)
     : base(listBox, myName)
 {
     Weapon = new Bow();
 }
Exemplo n.º 19
0
 public Troll(ListBox listBox, String myName) : base(listBox, myName)
 {
     Weapon = new Bow();
 }
Exemplo n.º 20
0
 public Queen(String name)
     : base(name)
 {
     Weapon = new Bow();
 }
Exemplo n.º 21
0
 public Troll(string name) :
     base(name)
 {
     base.name = name;
     weapon    = new Bow();
 }
Exemplo n.º 22
0
        private void button1_Click(object sender, EventArgs e)
        {
            IWeapon newWeapon = null;
            if (rdBow.Checked)
            {
                newWeapon = new Bow();
            }
            else if (rdSword.Checked)
            {
                newWeapon = new Sword();
            }
            else if (rdKnife.Checked)
            {
                newWeapon = new Knife();
            }

            if (newWeapon == null)
            {
                MessageBox.Show("Please select a new weapon.");
            }
            else
            {
                foreach (int indexChecked in checkedListBox2.CheckedIndices)
                {
                    Character c = characterList[indexChecked];
                    c.ChangeWeapon(newWeapon);
                }
            }
        }