You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

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<Cell>().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<Cell>().SetOccupied(false);
InventoryManager.RefreshItem();
Destroy(gameObject);
}
}