186 lines
5.7 KiB
C#
186 lines
5.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class L9Ctrl : MonoBehaviour
|
|
{
|
|
private int Etapa = 0;
|
|
private Text op1, op2, op3,op4, Enunciado, bend;
|
|
private Color defaultA = new Color(0, 0, 0, 255);
|
|
public AudioSource audioAcertos, audioCompleto;
|
|
public AudioClip[] audiosDialogo;
|
|
public AudioClip correct, wrong;
|
|
private bool Ended = false;
|
|
public bool Game11;
|
|
public GameObject btnaudio;
|
|
public List<Opcao> Questoes;
|
|
[System.Serializable]
|
|
public class Opcao
|
|
{
|
|
public string Op1, Op2, Op3,Op4, Certo, Enunciado;
|
|
public Color cenn;
|
|
}
|
|
public List<Enunciados2> enunciados2s;
|
|
[System.Serializable]
|
|
public class Enunciados2
|
|
{
|
|
public string Enunciado2;
|
|
public Color cenun;
|
|
}
|
|
|
|
|
|
// Start is called before the first frame update
|
|
void Awake()
|
|
{
|
|
op1 = GameObject.Find("TextOp1").GetComponent<Text>();
|
|
op2 = GameObject.Find("TextOp2").GetComponent<Text>();
|
|
op3 = GameObject.Find("TextOp3").GetComponent<Text>();
|
|
op4 = GameObject.Find("TextOp4").GetComponent<Text>();
|
|
Enunciado = GameObject.Find("Enunciado").GetComponent<Text>();
|
|
|
|
if(Game11 == true)
|
|
{
|
|
bend = GameObject.Find("Final").GetComponent<Text>();
|
|
btnaudio.SetActive(false);
|
|
op1.text = Questoes[Etapa].Op1;
|
|
op2.text = Questoes[Etapa].Op2;
|
|
op3.text = Questoes[Etapa].Op3;
|
|
op4.text = Questoes[Etapa].Op4;
|
|
Enunciado.text = enunciados2s[0].Enunciado2;
|
|
Enunciado.color = enunciados2s[0].cenun;
|
|
Enunciado.color += defaultA;
|
|
bend.text = Questoes[Etapa].Enunciado;
|
|
}
|
|
else
|
|
{
|
|
op1.text = Questoes[Etapa].Op1;
|
|
op2.text = Questoes[Etapa].Op2;
|
|
op3.text = Questoes[Etapa].Op3;
|
|
op4.text = Questoes[Etapa].Op4;
|
|
Enunciado.color += defaultA;
|
|
Enunciado.text = Questoes[Etapa].Enunciado;
|
|
Enunciado.color = Questoes[Etapa].cenn;
|
|
StartCoroutine(playAudioSequentially());
|
|
|
|
}
|
|
|
|
GameControl jooj = GameObject.Find("GameControl").GetComponent<GameControl>();
|
|
jooj.ended = false;
|
|
jooj.finishedGame = false;
|
|
jooj.failedGame = false;
|
|
}
|
|
|
|
|
|
public void VerificaResposta(Text Answer)
|
|
{
|
|
if (!Ended)
|
|
{
|
|
Text txtAnswer = Answer.gameObject.GetComponentInChildren<Text>();
|
|
if (txtAnswer.text == Questoes[Etapa].Certo)
|
|
{
|
|
if ((Etapa + 1) == Questoes.Count)
|
|
{
|
|
CorrectSound();
|
|
if(Game11 == true)
|
|
{
|
|
win();
|
|
}
|
|
else
|
|
{
|
|
StartCoroutine(endgame(1f));
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
CorrectSound();
|
|
Etapa++;
|
|
op1.text = Questoes[Etapa].Op1;
|
|
op1.color = Color.black;
|
|
op2.text = Questoes[Etapa].Op2;
|
|
op2.color = Color.black;
|
|
op3.text = Questoes[Etapa].Op3;
|
|
op3.color = Color.black;
|
|
op4.text = Questoes[Etapa].Op4;
|
|
op4.color = Color.black;
|
|
if(Game11 == true)
|
|
{
|
|
if (Game11 == true && (Etapa + 1) == Questoes.Count)
|
|
{
|
|
Enunciado.text = Questoes[Etapa].Enunciado;
|
|
Enunciado.color = Questoes[Etapa].cenn;
|
|
bend.text = enunciados2s[1].Enunciado2;
|
|
bend.color = enunciados2s[1].cenun;
|
|
Enunciado.color += defaultA;
|
|
bend.color += defaultA;
|
|
|
|
}
|
|
else
|
|
{
|
|
Enunciado.color += defaultA;
|
|
Enunciado.text = Questoes[Etapa].Enunciado;
|
|
Enunciado.color = Questoes[Etapa].cenn;
|
|
bend.text = "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Enunciado.color += defaultA;
|
|
Enunciado.text = Questoes[Etapa].Enunciado; Enunciado.color = Questoes[Etapa].cenn;
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
WrongSound();
|
|
Answer.color = new Color(0.9245283f, 0.2660199f, 0.2660199f, 1);
|
|
txtAnswer.text = "Wrong";
|
|
txtAnswer.color = Color.white;
|
|
}
|
|
}
|
|
}
|
|
|
|
void win()
|
|
{
|
|
GameControl jooj = GameObject.Find("GameControl").GetComponent<GameControl>();
|
|
jooj.finishedGame = true;
|
|
}
|
|
IEnumerator endgame(float wait)
|
|
{
|
|
yield return new WaitForSeconds(wait);
|
|
win();
|
|
}
|
|
|
|
void CorrectSound()
|
|
{
|
|
audioAcertos.clip = correct;
|
|
audioAcertos.Play();
|
|
}
|
|
void WrongSound()
|
|
{
|
|
audioAcertos.clip = wrong;
|
|
audioAcertos.Play();
|
|
}
|
|
|
|
public void Audio()
|
|
{
|
|
StartCoroutine(playAudioSequentially());
|
|
}
|
|
IEnumerator playAudioSequentially()
|
|
{
|
|
yield return null;
|
|
for (int i = 0; i < audiosDialogo.Length; i++)
|
|
{
|
|
audioCompleto.clip = audiosDialogo[i];
|
|
audioCompleto.Play();
|
|
while (audioCompleto.isPlaying)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|