EquipToHero() public méthode

The equipment will pass abilities on, so the hero is able to use them.
public EquipToHero ( Hero hero ) : void
hero Hero /// The hero that equips the equipment ///
Résultat void
Exemple #1
0
        /// <summary>
        /// Equip a weapon
        /// </summary>
        /// <param name="weapon">
        /// The weapon to be equipped
        /// </param>
        public void EquipWeapon(Equipment weapon)
        {
            Contract.Requires(weapon != null);
            Contract.Requires(weapon.Type == EquipmentType.Weapon);
            Contract.Requires(weapon.Hands <= FreeHands);
            Contract.Ensures(inventory[(int)EquipmentSlot.Weapon] == weapon);
            Contract.Ensures(FreeHands == Contract.OldValue(FreeHands) - weapon.Hands);

            inventory[(int)EquipmentSlot.Weapon] = weapon;
            weapon.EquipToHero(hero);
        }
Exemple #2
0
        /// <summary>
        /// Equip an item to potions.
        /// </summary>
        /// <param name="index">The indexwhere the item should be placed.</param>
        /// <param name="item">The item to place.</param>
        public void EquipToPotions(int index, Equipment item)
        {
            Contract.Requires(0 < index && index < MaxPotions);
            Contract.Requires(item != null);
            Contract.Requires(item.Type == EquipmentType.Potion);
            Contract.Requires(this[(int)EquipmentSlot.Potion + index] == null);
            Contract.Ensures(this[(int)EquipmentSlot.Potion + index] == item);

            inventory[(int)EquipmentSlot.Potion + index] = item;
            item.EquipToHero(hero);
        }
Exemple #3
0
        /// <summary>
        /// Equip an item to 'other'.
        /// </summary>
        /// <param name="index">The index where the item should be placed.</param>
        /// <param name="item">The item to place.</param>
        public void EquipToOther(int index, Equipment item)
        {
            Contract.Requires(0 < index && index < MaxOtherItems);
            Contract.Requires(item != null);
            Contract.Requires(item.Type == EquipmentType.Other);
            Contract.Requires(this[(int)EquipmentSlot.Other + index] == null);
            Contract.Ensures(this[(int)EquipmentSlot.Other + index] == item);

            inventory[(int)EquipmentSlot.Other + index] = item;
            item.EquipToHero(hero);
        }
Exemple #4
0
        /// <summary>
        /// Equip an item to backpack.
        /// </summary>
        /// <param name="index">The index where the item should be placed.</param>
        /// <param name="item">The item to place.</param>
        public void EquipToBackpack(int index, Equipment item)
        {
            Contract.Requires(0 < index && index < MaxInBackpack);
            Contract.Requires(item != null);
            Contract.Requires(this[(int)EquipmentSlot.Backpack + index] == null);
            Contract.Ensures(this[(int)EquipmentSlot.Backpack + index] == item);

            inventory[(int)EquipmentSlot.Backpack + index] = item;
            item.EquipToHero(hero);
        }
Exemple #5
0
        /// <summary>
        /// Equip a shield.
        /// </summary>
        /// <param name="shield">
        /// The shield to be equipped
        /// </param>
        public void EquipShield(Equipment shield)
        {
            Contract.Requires(shield != null);
            Contract.Requires(shield.Type == EquipmentType.Shield);
            Contract.Requires(shield.Hands <= FreeHands);
            Contract.Ensures(this[(int)EquipmentSlot.Shield] == shield);
            Contract.Ensures(FreeHands == Contract.OldValue(FreeHands) - shield.Hands);

            inventory[(int)EquipmentSlot.Shield] = shield;
            shield.EquipToHero(hero);
        }
Exemple #6
0
        /// <summary>
        /// Equip an armor
        /// </summary>
        /// <param name="armor">
        /// The armor to be equipped
        /// </param>
        public void EquipArmor(Equipment armor)
        {
            Contract.Requires(armor != null);
            Contract.Requires(armor.Type == EquipmentType.Armor);
            Contract.Ensures(this[(int)EquipmentSlot.Armor] == armor);

            inventory[(int)EquipmentSlot.Armor] = armor;
            armor.EquipToHero(hero);
        }