ZoeAppClass/Assets/Jogos/Aula13/DragTheWords/Scripts/A13DDropper.cs

31 lines
862 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class A13DDropper : MonoBehaviour, IDropHandler
{
private Text thisText;
public int thisIndex = 0;
public void SetupThis(int index)
{
thisIndex = index;
}
public void OnDrop(PointerEventData data)
{
if (data.pointerDrag.GetComponent<A13DDragger>().thisAnswer.position == thisIndex)
{
thisText = GetComponent<Text>();
thisText.text = data.pointerDrag.GetComponent<A13DDragger>().thisAnswer.answerStr;
data.pointerDrag.GetComponent<A13DDragger>().isAnswered = true;
A13DQuestionManager.instance.CorrectAnswer();
}
else
{
A13DQuestionManager.instance.WrongAnswer();
}
}
}