51 lines
1.3 KiB
C#
51 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class A9GDrop : MonoBehaviour, IDropHandler
|
|
{
|
|
private Text thisText;
|
|
public int index = 9;
|
|
|
|
public void Awake()
|
|
{
|
|
thisText = GetComponent<Text>();
|
|
}
|
|
|
|
public void SetupThis(string txt, int id = 9)
|
|
{
|
|
|
|
thisText = GetComponent<Text>();
|
|
index = id;
|
|
thisText.text = txt;
|
|
}
|
|
|
|
public void OnDrop(PointerEventData data)
|
|
{
|
|
A9GDrag received;
|
|
if (data.pointerDrag.gameObject.GetComponent<A9GDrag>())
|
|
{
|
|
received = data.pointerDrag.gameObject.GetComponent<A9GDrag>();
|
|
if (received.thisAnswer.isCorrect)
|
|
{
|
|
if (received.thisAnswer.indexToSet == index && !received.answered)
|
|
{
|
|
received.answered = true;
|
|
thisText.text = received.thisAnswer.answer;
|
|
A9GQuestionManager.instance.CorrectAnswer();
|
|
}
|
|
else
|
|
{
|
|
A9GAudioSystem.instance.PlayWrong();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
A9GAudioSystem.instance.PlayWrong();
|
|
}
|
|
}
|
|
}
|
|
}
|