Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.Diagnostics;
- public class PlayerInventory : MonoBehaviour
- {
- public delegate void PickupAction(InventoryObject _inventory);
- public static event PickupAction OnItemPickedUp;
- public InventoryObject inventory;
- // Start is called before the first frame update
- public void Start()
- {
- }
- public void OnTriggerEnter2D(Collider2D other)
- {
- var item = other.GetComponent<renderItemSprite>().equipment;
- if (item)
- {
- UnityEngine.Debug.Log("Player-Item collision!");
- inventory.AddItem(item, 1);
- Destroy(other.gameObject);
- if(OnItemPickedUp != null)
- {
- OnItemPickedUp(inventory);
- UnityEngine. Debug.Log("Item Pickup Event Raised!");
- }
- }
- }
- private void OnApplicationQuit()
- {
- inventory.Container.Clear();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement