using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using TMPro;

public class DragDropW : MonoBehaviour, IDragHandler, IDropHandler
{

    [SerializeField] private Canvas canvas;

    private RectTransform rectransform;
    public TMP_Text textshowed;
    bool block = true;


    private void Awake()
    {
        rectransform = GetComponent<RectTransform>();
        
    }
 

    public void OnDrag(PointerEventData eventData)
    {

        if (Ui.nbObst == 0)
        {
            Destroy(this.gameObject);
            Ui.nbObst++;
        }
        else
        {
            rectransform.anchoredPosition += eventData.delta / canvas.scaleFactor;
        }
    }

    public void OnDrop(PointerEventData eventData)
    {
        
        while(block == true)
        {

            Ui.nbObst = Ui.nbObst - 1;
            Ui.difficulty = Ui.difficulty + 1;


            block = false;
        }



    }
}