PJ/Assets/scripts/Blocks/Items.cs

40 lines
826 B
C#

using UnityEngine;
public class Items : MonoBehaviour
{
public int Count;
public string Item;
public bool IsList;
public int id;
public float time;
void Start()
{
if (time != 0)
{
Invoke("Dest", time);
}
}
void OnTriggerEnter2D(Collider2D collision)
{
if(collision.tag == "Player")
{
if (!IsList)
{
Count += PlayerPrefs.GetInt(Item);
PlayerPrefs.SetInt(Item, Count);
}
else
{
int cur = Currencies.Load(Item)[id] + Count;
Currencies.SaveV(Item, id, cur);
}
Destroy(this.gameObject);
}
}
void Dest()
{
Destroy(this.gameObject);
}
}