コード例 #1
0
        public void equip(string slot, string itemKey) //Handles equipping all equipment
        {
            equipUnequipSB.equipunequipsb.Clear();     //Clears the equip and unequip string builder
            switch (slot)                              //Checks if the input is the correct slot for equipment
            {
            case "HELMET":
            case "CHEST":
            case "HAND":
            case "WAIST":
            case "LEG":
            case "BOOT":
            case "NECK":
            case "WRIST":
            case "RING1":
            case "RING2":
                PlayerCharacter.theCharacter.playerEquipmentSlots[slot] = PlayerCharacter.theCharacter.playerEquipment[itemKey];            //Assigns the equipment item to the correct equipment slot
                equipUnequipSB.equipunequipsb.Append("You equip the " + PlayerCharacter.theCharacter.playerEquipment[itemKey].name + "\n"); //Displays text for equipping the equipment
                PlayerCharacter.theCharacter.playerEquipment[itemKey].current -= 1;                                                         //Removes a quantity of 1 from the equipment inventory
                PlayerCharacter.theCharacter.playerEquipment[itemKey].applyAttributes();                                                    //Adds the attribute bonuses from the equipment to the player
                break;

            default:    //If no correct slot is chosen nothing happens
                break;
            }
            ConsoleSpecificTextDisplay.writeEquipUnequip();
        }
コード例 #2
0
        public void unequip(string slot, string itemkey) //Handles unequipping all equipment
        {
            equipUnequipSB.equipunequipsb.Clear();       //Clears the equip and unequip string builder
            switch (slot.ToUpper())                      //Checks if the input is the correct slot for equipment
            {
            case "HELMET":
            case "CHEST":
            case "HAND":
            case "WAIST":
            case "LEG":
            case "BOOT":
            case "NECK":
            case "WRIST":
            case "RING1":
            case "RING2":
                foreach (GenericEquipment item in PlayerCharacter.theCharacter.playerEquipment.Values)                                                //Iterates through the player equipment
                {
                    if (PlayerCharacter.theCharacter.playerEquipmentSlots[slot].name == item.name)                                                    //If the current equipment name is equal to the equipped equipments name
                    {
                        PlayerCharacter.theCharacter.playerEquipment[itemkey].current++;                                                              //Adds a quantity of 1 to the players equipment inventory for the desired equipment item
                        PlayerCharacter.theCharacter.playerEquipmentSlots[slot].removeAttributes();                                                   //Removes the attributes applied by the equipment item
                        PlayerCharacter.theCharacter.playerEquipmentSlots[slot] = Equipment.iEquipmentMasterList["Empty"];                            //Assigns the players equipment slot to be empty
                        equipUnequipSB.equipunequipsb.Append("You unequip the " + PlayerCharacter.theCharacter.playerEquipment[itemkey].name + "\n"); //Writes the unequip message to the console window
                        break;
                    }
                }
                break;

            default:    //If no matches are found nothing happens
                break;
            }
            ConsoleSpecificTextDisplay.writeEquipUnequip();
        }