using UnityEngine;
using DG.Tweening;

public class ObjectData : MonoBehaviour
{
	public int objectTypeId;
	public float lifeTime;

	private GameManager gameManager;
	private float timeLeft;

	private void Awake()
	{
		gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
	}

	private void Start()
	{
		Reset();
	}

	private void Update()
	{
		/*if(gameManager.IsPaused())
		{
			return;
		}*/

		timeLeft -= Time.deltaTime;

		if(timeLeft <= 0f)
		{
			Recycle();
		}
	}

	public void Reset()
	{
		timeLeft = lifeTime;
	}

	public void Recycle()
	{
		this.transform.DOScale(0f, 1f).OnComplete(() => { Object.Destroy(this.gameObject); });
	}
}
