Scriptum/Assets/Scripts/Item/PickableController.cs

30 lines
694 B
C#
Raw Normal View History

2022-04-19 16:18:30 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2022-05-15 18:54:59 +02:00
public class PickableController : MonoBehaviour
2022-04-19 16:18:30 +02:00
{
2022-05-15 18:54:59 +02:00
public Item item;
public void Start()
{
item.Name = gameObject.name;
string pickaxe = PlayerPrefs.GetString("pickaxe1");
if(pickaxe == "picked")
{
Destroy(gameObject);
}
2022-05-15 18:54:59 +02:00
}
2022-04-19 16:18:30 +02:00
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.tag == "Player")
{
2022-05-15 18:54:59 +02:00
InventoryManager.Instance.AddToInventory(this.item);
string pickaxe = "picked";
PlayerPrefs.SetString("pickaxe1", pickaxe);
2022-04-19 16:18:30 +02:00
Destroy(gameObject);
}
}
}