Example #1
0
 public InventorySlot(int id, InteractorType item, int amount, float itemDurability)
 {
     Item           = item;
     Amount         = amount;
     ItemUniqueID   = id;
     ItemDurability = itemDurability;
 }
 public void Deselect()
 {
     if (_selectedItem != null)
     {
         _selectedItem = null;
     }
 }
        public void Remove(InteractorType item)
        {
            if (_selectedItem == item)
            {
                _selectedItem = null;
            }

            for (int i = 0; i < Slots.Count; i++)
            {
                if (Slots[i].Item == item)
                {
                    if (Slots[i].Amount > 1)
                    {
                        Slots[i].RemoveAmount(1);
                    }
                    else
                    {
                        Slots.RemoveAt(i);
                    }

                    InventoriesManagerEvents.OnItemRemoved();
                    return;
                }
            }
        }
        public bool Add(InteractorType item, bool isStackable, float itemDurability)
        {
            if (isStackable && Slots.Count > 0)
            {
                for (int i = 0; i < Slots.Count; i++)
                {
                    if (Slots[i].Item == item)
                    {
                        Slots[i].AddAmount(1);
                        InventoriesManagerEvents.OnItemAdd();
                        return(true);
                    }
                }
            }

            if (Slots.Count >= _availableSlots)
            {
                InventoriesManagerEvents.OnInventoryFull();
                return(false);
            }

            Slots.Add(new InventorySlot(item.UniqueID, item, 1, itemDurability));
            InventoriesManagerEvents.OnItemAdd();
            return(true);
        }
        private void OnEnable()
        {
            _selectedItem = null;

            if (string.IsNullOrEmpty(Name))
            {
                Name = string.Concat("Inventory_", _Id);
            }
        }
 public void SelectItem(uint inventoryID, InteractorType item)
 {
     foreach (Inventory inventory in Inventories)
     {
         if (inventory.ID == inventoryID)
         {
             inventory.Select(item);
         }
     }
 }
 public void RemoveItem(uint inventoryID, InteractorType item)
 {
     foreach (Inventory inventory in Inventories)
     {
         if (inventory.ID == inventoryID)
         {
             inventory.Remove(item);
         }
     }
 }
Example #8
0
    void processCollision(InteractorType x, GeneralCollider gc)
    {
        if(a.ContainsKey(x)) {
            //logInteraction(a[x], gc.go);
            changeTarget.addChange(a [x]);
            return;
        }

        if(a.ContainsKey(InteractorType.DEFAULT)) {
            changeTarget.addChange(a [InteractorType.DEFAULT]);
        }
    }
        public bool AddItem(uint inventoryID, InteractorType item, bool isStackable, float itemDurability)
        {
            foreach (Inventory inventory in Inventories)
            {
                if (inventory.ID == inventoryID)
                {
                    if (inventory.Add(item, isStackable, itemDurability))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            return(false);
        }
 public void Select(InteractorType item)
 {
     _selectedItem = item;
 }
Example #11
0
 public void logInteractionCheck(InteractorType t)
 {
     Debug.Log ("<" + this + "> checking interaction with <" + t + "> on behalf of <" + changeTarget + ">");
 }
        public void MoveItemBetweenInventories(uint fromInventoryID, uint toInventoryID, InteractorType item)
        {
            throw new System.NotImplementedException();

            //foreach (Inventory inventory in Inventories)
            //{
            //    if (inventory.ID == fromInventoryID)
            //    {
            //        inventory.Remove(item);
            //    }
            //    if(inventory.ID == toInventoryID)
            //    {
            //        inventory.Add(item);
            //    }
            //}
        }