Scriptum/Assets/Scripts/Item/PickableController.cs

31 lines
718 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-29 12:33:43 +02:00
using System;
2022-04-19 16:18:30 +02:00
2022-05-15 18:54:59 +02:00
public class PickableController : MonoBehaviour
2022-04-19 16:18:30 +02:00
{
2022-05-29 21:54:28 +02:00
public EquippableItem item;
2022-05-15 18:54:59 +02:00
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);
}
}
}