151 lines
3.8 KiB
C#
151 lines
3.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.InteropServices;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class L20Plane_Controller : MonoBehaviour
|
|
{
|
|
|
|
[DllImport("__Internal")]
|
|
private static extern void FinishedGame();
|
|
|
|
[DllImport("__Internal")]
|
|
private static extern void FailedGame();
|
|
|
|
private int Question = 1, VidasN = 5;
|
|
|
|
public Text Btn1, Btn2, Btn3, Vidas, Distancia;
|
|
public Animator Anime1, Anime2, Anime3, Anime4;
|
|
public Animator AnimeA1, AnimeA2, AnimeA3, AnimeA4;
|
|
|
|
public CanvasGroup Win, Fail;
|
|
private int Encerrar = 0;
|
|
|
|
private bool Ended = false;
|
|
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
Anime1.SetBool("Appear", true);
|
|
AnimeA1.SetBool("Appear", true);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (Encerrar == 1) {
|
|
STARTENDING.Encerrar(Fail);
|
|
FailedGame();
|
|
}
|
|
if (Encerrar == 2) {
|
|
Ended = true;
|
|
STARTENDING.Encerrar(Win);
|
|
FinishedGame();
|
|
}
|
|
}
|
|
|
|
public void Botao1() {
|
|
if (!Ended)
|
|
{
|
|
switch (Question)
|
|
{
|
|
case 1:
|
|
ObjDestroy(Anime1.gameObject, AnimeA1.gameObject);
|
|
Acertou(Anime2, AnimeA2, "Canada", "Egipt", "EUA", "Where are you travelling to?");
|
|
break;
|
|
case 2:
|
|
Erro(Btn1);
|
|
break;
|
|
case 3:
|
|
Erro(Btn1);
|
|
break;
|
|
case 4:
|
|
Erro(Btn1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Botao2()
|
|
{
|
|
if (!Ended)
|
|
{
|
|
switch (Question)
|
|
{
|
|
case 1:
|
|
Erro(Btn2);
|
|
break;
|
|
case 2:
|
|
Erro(Btn2);
|
|
break;
|
|
case 3:
|
|
ObjDestroy(Anime3.gameObject, AnimeA3.gameObject);
|
|
Acertou(Anime4, AnimeA4, "Japan", "Indonesia", "Korea", "Where are you travelling to?");
|
|
break;
|
|
case 4:
|
|
Encerrar = 2;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Botao3()
|
|
{
|
|
if (!Ended)
|
|
{
|
|
switch (Question)
|
|
{
|
|
case 1:
|
|
Erro(Btn3);
|
|
break;
|
|
case 2:
|
|
ObjDestroy(Anime2.gameObject, AnimeA2.gameObject);
|
|
Acertou(Anime3, AnimeA3, "Chile", "Madagascar", "Mexico", "Where are you travelling to?");
|
|
break;
|
|
case 3:
|
|
Erro(Btn3);
|
|
break;
|
|
case 4:
|
|
Erro(Btn3);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
void Erro(Text Texto) {
|
|
Texto.fontSize = 18;
|
|
Texto.color = Color.red;
|
|
Texto.text = "Check your answer";
|
|
VidasN -= 1;
|
|
if (VidasN == 0) { Encerrar = 1; Ended = true; }
|
|
Vidas.text = "0" + VidasN;
|
|
}
|
|
|
|
void Acertou(Animator anime, Animator animeA, string op1, string op2, string op3, string dist) {
|
|
anime.SetBool("Appear", true);
|
|
animeA.SetBool("Appear", true);
|
|
Question++;
|
|
Btn1.fontSize = 36;
|
|
Btn1.color = Color.black;
|
|
Btn1.text = op1;
|
|
Btn2.fontSize = 36;
|
|
Btn2.color = Color.black;
|
|
Btn2.text = op2;
|
|
Btn3.fontSize = 36;
|
|
Btn3.color = Color.black;
|
|
Btn3.text = op3;
|
|
Distancia.text = dist;
|
|
}
|
|
|
|
void ObjDestroy(GameObject obj1, GameObject obj2)
|
|
{
|
|
Destroy(obj1); Destroy(obj2);
|
|
}
|
|
|
|
void AcertouUltimo() {
|
|
|
|
}
|
|
}
|