Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using UnityEngine;
- public class ItemPickup : MonoBehaviour
- {
- public Item item;
- private Inventory inventory;
- private InventoryUI inventoryUI;
- private void Start()
- {
- inventory = FindObjectOfType<Inventory>();
- inventoryUI = FindObjectOfType<InventoryUI>();
- }
- public void PickUp()
- {
- Debug.Log("Picking up " + item.name);
- Item foundedItem = inventory.items.Find(inventoryItem => inventoryItem.name == item.name);
- if (foundedItem != null)
- {
- foundedItem.amount = 5;
- inventoryUI.UpdateUI();
- inventory.Add(item);
- }
- Destroy(gameObject);
- }
- }
- public class InventoryUI : MonoBehaviour
- {
- public void UpdateUI() { }
- }
- public class Inventory : MonoBehaviour
- {
- public static Inventory instance;
- public List<Item> items;
- public void Add(Item item) { }
- }
- public class Item : ScriptableObject
- {
- public int amount;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement