Example #1
0
 public void AddItem(Game game, Item item, int number = 1)
 {
     for (int i = 0; i < number; ++i)
     {
         Item itemCopy = item.Copy(game);
         game._AddObject(itemCopy);
         Items.Add(itemCopy);
     }
 }
Example #2
0
        public bool MoveItemToSlot(Item item, string slotName, Config config)
        {
            var variable = GetVariableByName(slotName, config);

            if (item.Scheme == null || !SchemeExecutor.CheckTypeCompatibility(variable.Type, item.Scheme.Name, config))
            {
                return(false);
            }

            variable.Value = item;
            return(true);
        }
Example #3
0
 public void MoveItemToBag(Item item, Config config)
 {
     // we search for the slot in which the item is, and remove the item from it
     foreach (var slot in config.CharacterConfig.InventorySlots)
     {
         var slotVariable = GetVariableByName(slot.Name, config);
         if (slotVariable.Value == item)
         {
             slotVariable.Value = null;
             return;
         }
     }
 }
Example #4
0
        // used to evaluate classes that provide items for characters
        public void EvaluateClassItemSpellModifiers(Game game)
        {
            foreach (ObjectVariable var in Variables)
            {
                if (game.Config.IsClassType(var.Type))
                {
                    Class @class = (Class)var.Value;
                    List <ItemModifier> itemModifiers = @class.GetItemModifiers();
                    foreach (ItemModifier im in itemModifiers)
                    {
                        Item item = game.GetObjectById(im.ItemName);
                        AddItem(game, item, im.ItemNumber);
                    }

                    List <SpellModifier> spellModifiers = @class.GetSpellModifiers();
                    foreach (SpellModifier sm in spellModifiers)
                    {
                        Spell spell = game.GetObjectById(sm.SpellName);
                        AddSpell(spell);
                    }
                }
            }
        }
Example #5
0
 public void RemoveSpell(Spell spell)
 {
     Spells.Remove(spell);
 }
Example #6
0
 public void AddSpell(Spell spell)
 {
     Spells.Add(spell);
 }
Example #7
0
 public void RemoveItem(Item item, Config config)
 {
     MoveItemToBag(item, config); // remove item from slot (if inside one)
     Items.Remove(item);
 }
Example #8
0
 public void AddItemWithoutCopy(Item item)
 {
     Items.Add(item);
 }