using UnityEngine;
using System.Collections;

public class DragDrop : MonoBehaviour
{
    static Transform followed;

    private Item item;

    void Start()
    {
        item = this.GetComponent<Item>();
        print(item);
    }

    void OnMouseDown()
    {
        followed = this.transform;
    }

    void OnMouseUp()
    {
        followed = null;
        if (item != null)
        {
            Slot slot = item.getClosestSlot();
            if (slot == null)
            {
                item.reset();
            } else
            {
                slot.setItem(item);
            }
        }
		float prog = GameObject.FindObjectOfType<Person> ().checkRituals ();
		GameObject.FindObjectOfType<Balken>().setProgress(prog);
        print(prog);
    }

    public void Update()
    {
        if (followed == this.transform)
        {

            Vector3 myPosi = this.transform.position;
            Vector3 mousePosi = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            mousePosi.z = myPosi.z;

            this.transform.position = mousePosi;
        }

        //        Physics2D.
    }
}