Пример #1
0
        public Test()
        {
            EquipmentInventory i = new EquipmentInventory();

            Items.Equipment item = new Items.Equipment("armor_1", "test", EquipSlot.ARMOR);
            i.Add(item); // success
        }
Пример #2
0
 /*
  *  Removes an Item from the inventory, and sends it to Equip()
  */
 public bool EquipFromInventory(Items.Equipment item)
 {
     if (!inventory.EquipmentInventory.Contains(item))
     {
         return(false);
     }
     inventory.Remove(item);
     Equip(item);
     return(true);
 }
Пример #3
0
        /*
         *  Unequips an item, unequiping also removes any
         *  ability bonuses that item has.
         *  Places item into inventory
         */
        public void Unequip(Items.Equipment item)
        {
            foreach (Modifier mod in item.modifiers)
            {
                this.abilitiesHash[mod.attType].RemoveAllModifiersFromSource(item);
            }

            currentlyEquipped.Remove(item.equipSlot);
            inventory.Add(item);
        }
Пример #4
0
        /*
         *  Only Builds Equipment,
         *  This may introduce duplicates, it doesn't route through the EquipmentQueue
         */
        private static Equipment BuildEquipment(string equipmentName)
        {
            Database database = new Database();
            Dictionary <string, object> itemData = database.GetItemData(equipmentName);

            Items.Equipment item = new Items.Equipment((string)itemData["display_name"], (string)itemData["name"], StringToEquipSlot((string)itemData["slot"]));
            foreach (KeyValuePair <string, long> row in (Dictionary <string, long>)itemData["modifiers"])
            {
                item.AddStatMod(new Modifier((int)row.Value, ModifierType.Flat, item, StringToAbilityType(row.Key)));
            }

            Debug.Log("Building: " + item.ToString());

            return(item);
        }
Пример #5
0
 /// Equips an item into the currentlyEquipped dictionary,
 /// also adds the items ability modifiers to the creature
 // If equip slot is filled, currently equiped item goes into
 // the inventory, and the given item is equiped in it's place
 public void Equip(Items.Equipment item)
 {
     // Debug.Log("Equipping: " + item.ToString());
     foreach (Modifier mod in item.modifiers)
     {
         this.abilitiesHash[mod.attType].AddModifier(mod);
     }
     if (!this.currentlyEquipped.ContainsKey(item.equipSlot))
     {
         this.currentlyEquipped.Add(item.equipSlot, item);
     }
     else
     {
         Unequip(item.equipSlot);
         this.currentlyEquipped.Add(item.equipSlot, item);
     }
 }
Пример #6
0
        // builds all equipment in data.xml, for testing
        private static List <Equipment> BuildAllEquipment()
        {
            Database         database = new Database();
            List <Equipment> result   = new List <Equipment>();
            List <Dictionary <string, object> > itemDataList = database.GetAllEquipmentData();

            Debug.Log(itemDataList.Count);
            foreach (Dictionary <string, object> itemData in itemDataList)
            {
                Items.Equipment temp = new Items.Equipment((string)itemData["display_name"], (string)itemData["name"], StringToEquipSlot((string)itemData["slot"]));
                foreach (KeyValuePair <string, long> row in (Dictionary <string, long>)itemData["modifiers"])
                {
                    temp.AddStatMod(new Modifier((int)row.Value, ModifierType.Flat, temp, StringToAbilityType(row.Key)));
                }
                result.Add(temp);
            }
            return(result);
        }