ZoeAppClass/Assets/Jogos/Aula08/Aula8-Colours/Scripts/A8CAnswerButton.cs

55 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class A8CAnswerButton : MonoBehaviour
{
public bool isTesting;
private Image thisImage;
private Button thisBtn;
private A8CAnswerClass thisAnswer;
private Animator anim;
private int thisIndex;
private void Awake()
{
anim = GetComponent<Animator>();
thisBtn = GetComponent<Button>();
thisImage = GetComponent<Image>();
thisBtn.onClick.AddListener(TestAnswer);
}
public void TestAnswer()
{
A8CQuestionManager.instance.TestIfCorrect(thisIndex, transform.gameObject);
}
public void Correct()
{
anim.SetTrigger("Correct");
thisBtn.interactable = false;
}
public void Wrong()
{
anim.SetTrigger("Wrong");
}
public void SetupThis(A8CAnswerClass receive, int index)
{
thisAnswer = receive;
thisIndex = index;
thisImage = GetComponent<Image>();
if (isTesting)
{
thisImage.color = thisAnswer.color;
}
else
{
thisImage.sprite = thisAnswer.image;
}
}
}