using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DropCube : MonoBehaviour {

	public ShapesEnum currentShape;

	public Sprite NoneSprite;

	private float lastTapTime = 0;

	// Use this for initialization
	void Start () {
		currentShape = ShapesEnum.SHAPE_NONE;
	}
	
	// Update is called once per frame
	void Update () {
		if(Input.GetMouseButtonUp(0) && ShapeDragging.DraggedShape != null)
		{
			if(GetComponent<Collider2D>().OverlapPoint(ShapeDragging.DraggedShape.transform.position))
			{
				GetComponent<SpriteRenderer>().sprite = ShapeDragging.DraggedShape.GetComponent<SpriteRenderer>().sprite;
				currentShape = ShapeDragging.DraggedShape.Shape;
			}
		}
		if(Input.GetMouseButtonDown(0) && GetComponent<Collider2D>().OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)))
		{
			if(Time.time - lastTapTime < 0.5f)
				Clean();
			else
				lastTapTime = Time.time;
		}
	}

	public void Clean()
	{
		GetComponent<SpriteRenderer>().sprite = NoneSprite;
		currentShape = ShapesEnum.SHAPE_NONE;
	}

}
