public override void OnPickUp(PlayerItemPickUpData data)
    {
        // Get Item Reference
        ConsumableItem consumableItem = Item as ConsumableItem;

        // Spawn Item
        if (Item.gameObject.IsPrefab())
        {
            consumableItem = ItemDB.Inst.SpawnItem(Item.GetType()).GetComponent <ConsumableItem>();
        }

        // Add To Inventory
        if (PlayerInventoryManager.consumableHotbar.TryAddItem(consumableItem))
        {
            goto EXIT;
        }

        if (PlayerInventoryManager.inventory.TryAddItem(consumableItem))
        {
            goto EXIT;
        }

        return;

EXIT:
        Destroy(gameObject);
    }
    public override void OnPickUp(PlayerItemPickUpData data)
    {
        // Get Item Reference
        ActiveItem activeItem = Item as ActiveItem;

        // Spawn Item
        if (Item.gameObject.IsPrefab())
        {
            activeItem = ItemDB.Inst.SpawnItem(Item.GetType()).GetComponent <ActiveItem>();
        }

        // Add To Inventory
        if (PlayerInventoryManager.inventory.TryUpgradeItem(activeItem.GetType()) ||
            PlayerInventoryManager.activeHotbar.TryUpgradeItem(activeItem.GetType()))
        {
            Destroy(activeItem.gameObject);
            goto EXIT;
        }

        if (PlayerInventoryManager.activeHotbar.TryAddItem(activeItem))
        {
            goto EXIT;
        }

        if (PlayerInventoryManager.inventory.TryAddItem(activeItem))
        {
            goto EXIT;
        }

        return;

EXIT:
        Destroy(gameObject);
    }
Beispiel #3
0
 public static void PickUp(this PlayerItemPickUpData data, Transform tf)
 {
     Collider2D[] items = Physics2D.OverlapCircleAll(tf.position, data.radius, data.layerMask);
     items.GetClosest <DroppedItem>(tf)?.OnPickUp(data);
 }
Beispiel #4
0
 public abstract void OnPickUp(PlayerItemPickUpData data);