A 2D Farming RPG
This is just a simple 2D farming RPG game
Loading...
Searching...
No Matches
ItemPickup.cs
Go to the documentation of this file.
1using UnityEngine;
2
3public class ItemPickup : MonoBehaviour
4{
10 private void OnTriggerEnter2D(Collider2D collision)
11 {
12 Item item = collision.GetComponent<Item>();
13
14 if( item != null )
15 {
16 ItemDetails itemDetails = InventoryManager.Instance.GetItemDetails( item.ItemCode );
17
18 // If item can be picked up
19 if( itemDetails.m_CanPickedUp == true )
20 {
21 // Add item to the inventory
22 InventoryManager.Instance.AddItem( InventoryLocation.Player, item, collision.gameObject );
23 }
24 }
25 }
26}
InventoryLocation
Describes the type of inventory and count Ex: player inventory or chest inventory
Definition: Enums.cs:108
This class will manage all the inventory related operations.
This class holds information of items.
Definition: ItemDetails.cs:8
bool m_CanPickedUp
Definition: ItemDetails.cs:20
void OnTriggerEnter2D(Collider2D collision)
Get item details from collided object if the item details class attached to that. Print the details f...
Definition: ItemPickup.cs:10
Definition: Item.cs:4
int ItemCode
Definition: Item.cs:11