using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class CtrlWeather : MonoBehaviour { private int Etapa = 0; public Text dropdown; public AudioSource audio; public Text enunciado; public AudioClip correct, wrong; public List Questoes; private bool Ended = false; [System.Serializable] public class Opcao { public string enunciado, certo; } void Awake() { dropdown = GameObject.Find("Dropdown").GetComponent(); enunciado = GameObject.Find("Enunciado").GetComponent(); enunciado.text = Questoes[Etapa].enunciado; GameControl.instance.StartedGame(); } public void VerificaResposta(Text Answer) { if (!Ended) { Text txtAnswer = Answer.gameObject.GetComponentInChildren(); if (txtAnswer.text == Questoes[Etapa].certo) { if ((Etapa + 1) == Questoes.Count) { CorrectSound(); GameControl.instance.FinishGame(); } else { CorrectSound(); StartCoroutine(CorrectAnime()); Etapa++; enunciado.text = Questoes[Etapa].enunciado; } } else { if (txtAnswer.text.Length > 0) { WrongSound(); } //txtAnswer.text = "Wrong"; } } } public GameObject objCanvasWait; public Dropdown dropAnswers; IEnumerator CorrectAnime() { objCanvasWait.SetActive(true); yield return new WaitForEndOfFrame(); Image imgAnime = objCanvasWait.GetComponentInChildren(); float timee = 0; while (timee < 1) { timee += Time.deltaTime * 3; imgAnime.color = new Color(.48f, 1, .35f, timee / 4); yield return new WaitForEndOfFrame(); } while (timee > 0) { timee -= Time.deltaTime * 3; imgAnime.color = new Color(.48f, 1, .35f, timee / 4); yield return new WaitForEndOfFrame(); } dropAnswers.value = 0; objCanvasWait.SetActive(false); yield break; } void CorrectSound() { audio.clip = correct; audio.Play(); } void WrongSound() { audio.clip = wrong; audio.Play(); } }