Exemplo n.º 1
0
 private void OnInventoryChanged(EventArgs e)
 {
     if (e is InventoryEvtArgs)
     {
         InventoryEvtArgs evt = (InventoryEvtArgs)e;
         m_items = evt.Items;
         UpdateUI();
     }
 }
Exemplo n.º 2
0
 private void OnAddItems(EventArgs e)
 {
     if (e is InventoryEvtArgs)
     {
         InventoryEvtArgs evt = (InventoryEvtArgs)e;
         foreach (var item in evt.Items)
         {
             Add(item);
         }
     }
 }
Exemplo n.º 3
0
        public void Remove(Item item)
        {
            if (item == null)
            {
                Debug.LogWarning("Trying to remove nothing from the Inventory; action ignored.");
                return;
            }

            if (Items.Remove(item))
            {
                InventoryEvtArgs args = new InventoryEvtArgs();
                args.Items = Items;
                EventManager.TriggerEvent(InventoryEvtType.Changed, args);
            }
            else
            {
                Debug.Log(item.name + " was not found in the Inventory.");
            }
        }
Exemplo n.º 4
0
        public bool Add(Item item)
        {
            if (item == null)
            {
                Debug.LogWarning("Trying to add nothing to the Inventory; action ignored.");
                return(false);
            }

            if (Items.Count >= m_space)
            {
                Debug.LogWarning("Inventory is full. Increase the size of the inventory or enable the player to drop items they no longer need.");
                return(false);
            }

            // Debug.Log(item.name + " added to the Inventory.");
            Items.Add(item);

            InventoryEvtArgs args = new InventoryEvtArgs();

            args.Items = Items;
            EventManager.TriggerEvent(InventoryEvtType.Changed, args);

            return(true);
        }