ZoeAppClass/Assets/Jogos/261/Scripts/ControlQuestions.cs

112 lines
3.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.UI;
public class ControlQuestions : MonoBehaviour
{
public static bool finishedGame = false;
public static bool ended = false;
int index = 0;
private Text Op1, Op2, Op3;
private Text Enunciado;
private int Etapa = 0;
private bool Ended = false;
public int Lifes; private Text LifeText;
public List<Opcao> Questoes;
private Animator WinPanel, LostPanel, MainAnime;
[System.Serializable]
public class Opcao {
public string Questao1, Questao2, Questao3, Enunciado, Certo;
}
// Start is called before the first frame update
void Start()
{
int index = 0;
ended = false;
finishedGame = false;
//GameControl jooj = GameObject.Find("GameControl").GetComponent<GameControl>();
//jooj.ended = false;
//jooj.finishedGame = false;
//jooj.failedGame = false;
WinPanel = GameObject.Find("YouWinPanel").GetComponent<Animator>();
LostPanel = GameObject.Find("GameOverPanel").GetComponent<Animator>();
Op1 = GameObject.Find("TextOp1").GetComponent<Text>();
Op2 = GameObject.Find("TextOp2").GetComponent<Text>();
Op3 = GameObject.Find("TextOp3").GetComponent<Text>();
Enunciado = GameObject.Find("Enunciado").GetComponent<Text>();
MainAnime = GameObject.Find("MainAnimation").GetComponent<Animator>();
LifeText = GameObject.Find("Lifes").GetComponent<Text>();
LifeText.text = "0" + Lifes.ToString();
Op1.text = Questoes[Etapa].Questao1;
Op2.text = Questoes[Etapa].Questao2;
Op3.text = Questoes[Etapa].Questao3;
Enunciado.text = Questoes[Etapa].Enunciado;
}
// Update is called once per frame
void Update()
{
}
public void VerificaResposta(Text Answer) {
if (!Ended)
{
if (Answer.text == Questoes[Etapa].Certo)
{
if ((Etapa + 1) == Questoes.Count)
{
WinPanel.SetBool("done", true);
Ended = true;
ended = true;
finishedGame = true;
win();
}
else
{
Etapa++;
Op1.text = Questoes[Etapa].Questao1;
Op2.text = Questoes[Etapa].Questao2;
Op3.text = Questoes[Etapa].Questao3;
Enunciado.text = Questoes[Etapa].Enunciado;
MainAnime.SetInteger("Etapa", MainAnime.GetInteger("Etapa") + 1);
}
}
else
{
Answer.text = "Wrong";
Lifes--; LifeText.text = "0" + Lifes.ToString();
if (Lifes == 0)
{
LostPanel.SetBool("done", true);
Ended = true;
Lost();
}
}
}
}
void win()
{
///GameControl jooj = GameObject.Find("GameControl").GetComponent<GameControl>();
//jooj.finishedGame = true;
}
void Lost()
{
// GameControl jooj = GameObject.Find("GameControl").GetComponent<GameControl>();
// jooj.failedGame = true;
}
}