Example #1
0
    public virtual void ModifyItem(ItemTypes type, int _delta)
    {
        if (Items == null)
        {
            return;
        }
        if (Items.Count == 0)
        {
            return;
        }

        IInventoryItem item = GetItem(type);

        int old_count = item.GetCount();

        if (item != null)
        {
            item.SetCount(Mathf.Max(0, Mathf.Min(GetMax(type), item.GetCount() + _delta)));
        }

        if (OnInventoryUpdated != null)
        {
            OnInventoryUpdated(item, item.GetCount() - old_count);
        }
    }
Example #2
0
    public void OnLoot(Unit _u)
    {
        int lootable_amount = GetLootableAmount(_u);

        if (lootable_amount > 0)
        {
            item_lootable.SetCount(item_lootable.GetCount() - lootable_amount);
            GetInventory(_u).ModifyItem(item_lootable.GetItemType(), lootable_amount);
        }

        crate.GetComponent <Animator>().SetTrigger("bOpened");

        if (item_lootable.GetCount() == 0)
        {
            StartCoroutine(M_Math.ExecuteDelayed(2f, RemoveLoot));
            // MDebug.Log("^loot removing loot soon");
        }
    }