62 lines
1.3 KiB
C#
62 lines
1.3 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class Maze_Answer : MonoBehaviour
|
|
{
|
|
public string thisAnswer;
|
|
private Text thisText;
|
|
public bool isCorrect, canActivate;
|
|
private bool alreadySentR = false;
|
|
|
|
public void Awake()
|
|
{
|
|
alreadySentR = false;
|
|
canActivate = false;
|
|
}
|
|
|
|
public void Setup(string answer, bool correct)
|
|
{
|
|
thisAnswer = answer;
|
|
isCorrect = correct;
|
|
if (!thisText)
|
|
{
|
|
thisText = GetComponentInChildren<Text>();
|
|
}
|
|
thisText.text = thisAnswer;
|
|
}
|
|
|
|
public void UpdateText()
|
|
{
|
|
if (!thisText)
|
|
{
|
|
thisText = GetComponentInChildren<Text>();
|
|
}
|
|
thisText.text = thisAnswer;
|
|
}
|
|
|
|
public void OnTriggerEnter2D(Collider2D col)
|
|
{
|
|
if(canActivate)
|
|
{
|
|
if (col.name == "Player")
|
|
{
|
|
if (isCorrect && !alreadySentR)
|
|
{
|
|
Maze_Manager.instance.ChangeQuestion();
|
|
alreadySentR = true;
|
|
}
|
|
else
|
|
{
|
|
Maze_Manager.instance.Restart();
|
|
alreadySentR = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ResetThis()
|
|
{
|
|
alreadySentR = false;
|
|
}
|
|
}
|