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-06-15 19:54:44 +02:00
|
|
|
public string name;
|
|
|
|
public string name2;
|
|
|
|
public bool triggered;
|
|
|
|
public int isPicked;
|
2022-05-15 18:54:59 +02:00
|
|
|
|
|
|
|
public void Start()
|
|
|
|
{
|
|
|
|
item.Name = gameObject.name;
|
2022-06-15 19:54:44 +02:00
|
|
|
if (PlayerPrefs.GetInt("continued") == 1)
|
|
|
|
{
|
|
|
|
isPicked = PlayerPrefs.GetInt(name2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
isPicked = PlayerPrefs.GetInt(name);
|
|
|
|
}
|
|
|
|
if(isPicked == 1)
|
2022-06-02 18:32:18 +02:00
|
|
|
{
|
2022-06-12 11:28:14 +02:00
|
|
|
gameObject.SetActive(false);
|
2022-06-02 18:32:18 +02:00
|
|
|
}
|
2022-05-15 18:54:59 +02:00
|
|
|
}
|
|
|
|
|
2022-06-15 19:54:44 +02:00
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
if(triggered)
|
|
|
|
{
|
|
|
|
if (Input.GetKeyDown(KeyCode.E))
|
|
|
|
{
|
|
|
|
InventoryManager.Instance.AddToInventory(this.item);
|
|
|
|
isPicked = 1;
|
|
|
|
PlayerPrefs.SetInt(name, isPicked);
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-19 16:18:30 +02:00
|
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
|
|
|
{
|
|
|
|
if (collision.tag == "Player")
|
|
|
|
{
|
2022-06-15 19:54:44 +02:00
|
|
|
triggered = true;
|
2022-04-19 16:18:30 +02:00
|
|
|
}
|
|
|
|
}
|
2022-06-15 19:54:44 +02:00
|
|
|
|
|
|
|
private void OnTriggerExit2D(Collider2D collision)
|
|
|
|
{
|
|
|
|
triggered = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SaveCheckpoint()
|
|
|
|
{
|
|
|
|
PlayerPrefs.SetInt(name2, isPicked);
|
|
|
|
}
|
|
|
|
|
2022-04-19 16:18:30 +02:00
|
|
|
}
|