120 lines
4.2 KiB
C#
120 lines
4.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class CtrlEstacoes : MonoBehaviour
|
|
{
|
|
public GameObject stage1, stage2, stage3, stage4, stage5, stage6;
|
|
public static bool finishedGame = false;
|
|
public static bool ended = false;
|
|
int index = 0;
|
|
private int pointstoWin;
|
|
private int Etapa;
|
|
private int currentPoints;
|
|
private AudioSource audio;
|
|
public Text enunciado, weatherTitle;
|
|
public AudioClip correct, wrong;
|
|
public Image bg;
|
|
public Image imagem;
|
|
public List<Opcao> Questoes;
|
|
|
|
[System.Serializable]
|
|
public class Opcao
|
|
{
|
|
public string Enunciado, Certo, weather;
|
|
public Sprite person, bg;
|
|
public AudioClip audio;
|
|
}
|
|
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
int index = 0;
|
|
ended = false;
|
|
finishedGame = false;
|
|
audio = GameObject.Find("People1").GetComponent<AudioSource>();
|
|
bg = GameObject.Find("bg").GetComponent<Image>();
|
|
imagem = GameObject.Find("People1").GetComponent<Image>();
|
|
enunciado = GameObject.Find("Enunciado").GetComponent<Text>();
|
|
weatherTitle = GameObject.Find("Enunciados").GetComponent<Text>();
|
|
|
|
GameControl jooj = GameObject.Find("GameControl").GetComponent<GameControl>();
|
|
jooj.ended = false;
|
|
jooj.finishedGame = false;
|
|
jooj.failedGame = false;
|
|
currentPoints = 0;
|
|
pointstoWin = 7;
|
|
bg.sprite = Questoes[Etapa].bg;
|
|
imagem.sprite = Questoes[Etapa].person;
|
|
}
|
|
|
|
public void VerificaResposta(Text Answer)
|
|
{
|
|
if (!ended)
|
|
{
|
|
Text txtAnswer = Answer.gameObject.GetComponentInChildren<Text>();
|
|
if (txtAnswer.text == Questoes[Etapa].Certo)
|
|
{
|
|
if ((Etapa + 1) == Questoes.Count)
|
|
{
|
|
enunciado.text = Questoes[Etapa].Enunciado;
|
|
CorrectSound();
|
|
StartCoroutine(resposta(1));
|
|
StartCoroutine(win(1));
|
|
|
|
}
|
|
else
|
|
{
|
|
enunciado.text = Questoes[Etapa].Enunciado;
|
|
txtAnswer.text = "Respondido";
|
|
StartCoroutine(resposta(1));
|
|
CorrectSound();
|
|
StartCoroutine(AvancaEtapa(4));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
WrongSound();
|
|
}
|
|
}
|
|
}
|
|
|
|
IEnumerator AvancaEtapa (float time)
|
|
{
|
|
yield return new WaitForSeconds(time);
|
|
Etapa++;
|
|
enunciado.text = "I wear ___________";
|
|
bg.sprite = Questoes[Etapa].bg;
|
|
if(Etapa == 1) { imagem.sprite = Questoes[Etapa].person;bg.sprite = Questoes[Etapa].bg; stage1.SetActive(false); stage2.SetActive(true);weatherTitle.text = Questoes[Etapa].weather; }
|
|
else if(Etapa == 2) { imagem.sprite = Questoes[Etapa].person;bg.sprite = Questoes[Etapa].bg; stage2.SetActive(false); stage3.SetActive(true); weatherTitle.text = Questoes[Etapa].weather; }
|
|
else if(Etapa == 3) { imagem.sprite = Questoes[Etapa].person;bg.sprite = Questoes[Etapa].bg; stage3.SetActive(false); stage4.SetActive(true); weatherTitle.text = Questoes[Etapa].weather; }
|
|
else if(Etapa == 4) { imagem.sprite = Questoes[Etapa].person;bg.sprite = Questoes[Etapa].bg; stage4.SetActive(false); stage5.SetActive(true); weatherTitle.text = Questoes[Etapa].weather; }
|
|
else if(Etapa == 5) { imagem.sprite = Questoes[Etapa].person;bg.sprite = Questoes[Etapa].bg; stage5.SetActive(false); stage6.SetActive(true); weatherTitle.text = Questoes[Etapa].weather; }
|
|
|
|
}
|
|
IEnumerator win(int time)
|
|
{
|
|
yield return new WaitForSeconds(time);
|
|
GameControl jooj = GameObject.Find("GameControl").GetComponent<GameControl>();
|
|
jooj.finishedGame = true;
|
|
}
|
|
public void CorrectSound()
|
|
{
|
|
audio.clip = correct;
|
|
audio.Play();
|
|
}
|
|
IEnumerator resposta(int time)
|
|
{
|
|
yield return new WaitForSeconds(time);
|
|
audio.clip = Questoes[Etapa].audio;
|
|
audio.Play();
|
|
}
|
|
public void WrongSound()
|
|
{
|
|
audio.clip = wrong;
|
|
audio.Play();
|
|
}
|
|
}
|