Esempio n. 1
0
        //populating the attack item list.
        //Constructor for inventory
        public Inventory()
        {
            _weaponList[0] = new AttackItem("Dagger", 10, 3);
            _weaponList[1] = new AttackItem("Sword", 15, 7);
            _weaponList[2] = new AttackItem("Scepter", 8, 8);
            _weaponList[3] = new AttackItem("Bow", 22, 12);

            _armorList[0] = new DefenseItem("Leather", 25, 5);
            _armorList[1] = new DefenseItem("Chain Mail", 35, 15);
            _armorList[2] = new DefenseItem("Plate", 50, 25);
            _armorList[3] = new DefenseItem("Robes", 0, 1);
        }
Esempio n. 2
0
        public void EquipArmor(DefenseItem newArmor)
        {
            if (_armor)
            {
                UnequipArmor(_currentArmor);

                _currentWeight += newArmor.weight;

                if (_currentWeight < _maxWeight)
                {
                    _defense = newArmor.Defense;

                    Console.WriteLine("You have swapped to " + newArmor.name + " armor");
                    Console.WriteLine("Defense: " + _defense);
                    Console.WriteLine("Weight: " + _currentWeight);
                    _armor        = true;
                    _currentArmor = newArmor;
                }
                else
                {
                    _currentWeight -= newArmor.weight;
                    Console.WriteLine("That item is too heavy");
                    _armor = false;
                }
            }
            else
            {
                _currentWeight += newArmor.weight;

                if (_currentWeight < _maxWeight)
                {
                    _defense = newArmor.Defense;

                    Console.WriteLine("You have swapped to " + newArmor.name + " armor");
                    Console.WriteLine("Defense: " + _defense);
                    Console.WriteLine("Weight: " + _currentWeight);
                    _armor        = true;
                    _currentArmor = newArmor;
                }
                else
                {
                    _currentWeight -= newArmor.weight;
                    Console.WriteLine("That item is too heavy");
                    _armor = false;
                }
            }
        }
Esempio n. 3
0
 public void UnequipArmor(DefenseItem armor)
 {
     _defense        = 0;
     _currentWeight -= armor.weight;
 }