using System.Collections; using System.Collections.Generic; using UnityEngine; public class ItemInMap : MonoBehaviour { public Item thisItem; public Inventory playerInventory; Vector2 lookDirection = new Vector2(0, -1); void Start() { RaycastHit2D hit = Physics2D.Raycast(transform.position, lookDirection, 1.0f, LayerMask.GetMask("Cells")); hit.collider.GetComponent().SetOccupied(true); } public void AddNewItem() { if (!playerInventory.itemList.Contains(thisItem)) { for (int i = 0; i < playerInventory.itemList.Count; i++) { if (playerInventory.itemList[i] == null) { playerInventory.itemList[i] = thisItem; break; } } } else { thisItem.itemHeld += 1; } RaycastHit2D hit = Physics2D.Raycast(transform.position, lookDirection, 1.0f, LayerMask.GetMask("Cells")); hit.collider.GetComponent().SetOccupied(false); InventoryManager.RefreshItem(); Destroy(gameObject); } }