920 lines
25 KiB
C#
920 lines
25 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.Networking;
|
|
using System.IO;
|
|
|
|
public class GeneralScript : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
public List<GroupColors> colorsGroups = new List<GroupColors>();
|
|
|
|
[System.Serializable]
|
|
public class GroupColors
|
|
{
|
|
public Color clara, escura;
|
|
}
|
|
|
|
|
|
Animator thisAnime;
|
|
public static GeneralScript instance;
|
|
public bool stepsReady;
|
|
public bool weakConnection;
|
|
GameObject avance;
|
|
|
|
#region public
|
|
public GroupColors activeColor;
|
|
public RectTransform rightrect, midrect, leftrect;
|
|
public ApiClass api;
|
|
public bool firstQuestion = true;
|
|
public int maxExercises, minExercises;
|
|
public Slider sliderProgress;
|
|
public ApiClass.EtapasResponse[] etapa;
|
|
#endregion
|
|
|
|
public static int idClasses;
|
|
GameObject sairAula;
|
|
bool inExercise = false;
|
|
public List<TypesClass.Questions> questions = new List<TypesClass.Questions>(); public int actualType;
|
|
int actualExercise = 0; public int completed = 0, stepstarted;
|
|
public List<int> animes = new List<int>();
|
|
|
|
//Videos Control
|
|
public List<string> links = new List<string>();
|
|
bool readAllVideos = false;
|
|
|
|
//Animations
|
|
public List<int> idAnimations = new List<int>();
|
|
public ApiClass.ResponseExerciseAnime[] exercisesAnime = null;
|
|
|
|
//Game
|
|
GameObject joojObject;
|
|
|
|
//Face - exercise
|
|
bool infaceExercise = false; public bool canRetry = true;
|
|
|
|
public bool doneLaunchingnotes = false;
|
|
int etapaPronto = 0;
|
|
GameObject load;
|
|
public string downloadingVideo;
|
|
|
|
WaitForEndOfFrame waitFrame = new WaitForEndOfFrame();
|
|
|
|
public void SetSlider()
|
|
{
|
|
sliderProgress.maxValue = maxExercises;
|
|
//sliderProgress.value = minExercises;
|
|
StartCoroutine(SliderPos(minExercises));
|
|
}
|
|
|
|
IEnumerator SliderPos(float value)
|
|
{
|
|
float startingvalue = sliderProgress.value;
|
|
float toFillValue = value - sliderProgress.value;
|
|
float time = 0;
|
|
while (time < 1)
|
|
{
|
|
time += Time.deltaTime * 2;
|
|
sliderProgress.value = startingvalue + (toFillValue * time);
|
|
|
|
yield return waitFrame;
|
|
}
|
|
|
|
sliderProgress.value = value;
|
|
}
|
|
|
|
void Awake()
|
|
{
|
|
load = transform.Find("Load").gameObject;
|
|
load.SetActive(false);
|
|
|
|
joojObject = GameObject.Find("GameControl");
|
|
//joojControl = joojObject.GetComponent<GameControl>();
|
|
joojObject.SetActive(false);
|
|
|
|
sairAula = GameObject.Find("GoOutScreen");
|
|
sairAula.SetActive(false);
|
|
|
|
firstQuestion = true;
|
|
|
|
sliderProgress = GameObject.Find("SliderProgress").GetComponent<Slider>();
|
|
|
|
idClasses = PlayerPrefs.GetInt("idClass");
|
|
//idClasses = 158;
|
|
instance = this;
|
|
|
|
avance = GameObject.Find("Avancar");
|
|
|
|
rightrect = GameObject.Find("RightRect").GetComponent<RectTransform>();
|
|
midrect = GameObject.Find("MiddleRect").GetComponent<RectTransform>();
|
|
leftrect = GameObject.Find("LeftRect").GetComponent<RectTransform>();
|
|
|
|
GameObject.Find("NomeAula").GetComponent<Text>().text = PlayerPrefs.GetString("NomeAula");
|
|
GameObject.Find("Descricao").GetComponent<Text>().text = PlayerPrefs.GetString("Desc");
|
|
|
|
thisAnime = GetComponent<Animator>();
|
|
|
|
api = GetComponent<ApiClass>();
|
|
|
|
StartCoroutine(api.getEtapas());
|
|
}
|
|
|
|
#region Exclude Old One
|
|
public void destroyNbrOne()
|
|
{
|
|
GameObject obj_01 = GameObject.Find("1");
|
|
|
|
Destroy(obj_01);
|
|
|
|
StartCoroutine(resetBundle());
|
|
}
|
|
|
|
IEnumerator resetBundle()
|
|
{
|
|
yield return waitFrame;
|
|
|
|
//Resources.UnloadUnusedAssets();
|
|
}
|
|
#endregion
|
|
|
|
#region Exercises
|
|
|
|
public void SpawnNextExercise()
|
|
{
|
|
ExercicioPronunciaFinalizado = false;
|
|
switch (actualType)
|
|
{
|
|
case 1:
|
|
GameObject spawnObj = Instantiate(Resources.Load<GameObject>("Class/Question"));
|
|
|
|
GlobalchangeofNames(spawnObj);
|
|
|
|
QuestionsController thisQuest = spawnObj.GetComponent<QuestionsController>();
|
|
int rand = Random.Range(0, colorsGroups.Count);
|
|
thisQuest.create(colorsGroups[rand], questions[actualExercise], actualExercise);
|
|
break;
|
|
case 5:
|
|
GameObject spawnObjj = Instantiate(Resources.Load<GameObject>("Class/Question"));
|
|
|
|
GlobalchangeofNames(spawnObjj);
|
|
|
|
QuestionsController thisQuest2 = spawnObjj.GetComponent<QuestionsController>();
|
|
int rand2 = Random.Range(0, colorsGroups.Count);
|
|
thisQuest2.create(colorsGroups[rand2], questions[actualExercise], actualExercise);
|
|
break;
|
|
case 4:
|
|
GameObject Face = Instantiate(Resources.Load<GameObject>("Class/FaceMitsuku"), transform);
|
|
|
|
GlobalchangeofNames(Face);
|
|
|
|
Conversation cv = Face.GetComponent<Conversation>();
|
|
cv.CorpoRequisicao.ChatTimeID = 0;
|
|
cv.CorpoRequisicao.IDAula = etapa[minExercises].idclasses;
|
|
cv.CorpoRequisicao.IDExercicio = etapa[minExercises].idexercises;
|
|
cv.exercisePhrase.Clear();
|
|
for (int i = 0; i < questions.Count; i++)
|
|
{
|
|
cv.exercisePhrase.Add(questions[i].enunciado);
|
|
}
|
|
bool teacher = ReadingFile.AllClassesUsers.Contains(ReadingFile.instance.userType);
|
|
|
|
cv.fakeStart(teacher, false, true);
|
|
|
|
infaceExercise = true;
|
|
break;
|
|
}
|
|
|
|
StartCoroutine(waitNShow());
|
|
|
|
//StartCoroutine(api.CheckStep());
|
|
}
|
|
|
|
public void FinishExercise()
|
|
{
|
|
questions.Clear();
|
|
inExercise = false;
|
|
actualExercise = 0;
|
|
|
|
infaceExercise = false;
|
|
canRetry = true;
|
|
|
|
Avancar();
|
|
}
|
|
|
|
void EndExerciseScreen()
|
|
{
|
|
GameObject endScreen = Instantiate(Resources.Load<GameObject>("Class/ConcluiuExercicio"));
|
|
GlobalchangeofNames(endScreen);
|
|
|
|
endController end = endScreen.GetComponent<endController>();
|
|
|
|
if (actualType == 4)
|
|
{
|
|
end.pronuncia = true;
|
|
}
|
|
else
|
|
{
|
|
end.pronuncia = false;
|
|
}
|
|
|
|
if (!canRetry)
|
|
{
|
|
Image restartimg = GameObject.Find("ReiniciarBtn").GetComponent<Image>();
|
|
Color oldColor = restartimg.color;
|
|
restartimg.color = new Color(oldColor.r, oldColor.g, oldColor.b, .5f);
|
|
|
|
endScreen.GetComponent<endController>().ListQuestions(questions);
|
|
}
|
|
|
|
StartCoroutine(waitNShow());
|
|
}
|
|
|
|
public void ResetExercise()
|
|
{
|
|
if (canRetry)
|
|
{
|
|
if (actualType != 4)
|
|
{
|
|
for (int i = 0; i < questions.Count; i++)
|
|
{
|
|
int removeIndex = api.updateStep.answersdb.Count - 1;
|
|
api.updateStep.answersdb.RemoveAt(removeIndex);
|
|
}
|
|
}
|
|
actualExercise = 0;
|
|
SpawnNextExercise();
|
|
|
|
canRetry = false;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Download Conteudo
|
|
public void StartDownloadVideosVoid()
|
|
{
|
|
StartCoroutine(startDownloadingVideos());
|
|
}
|
|
|
|
public IEnumerator startDownloadingVideos()
|
|
{
|
|
|
|
yield return waitFrame;
|
|
idAnimations.Clear();
|
|
|
|
Debug.Log(etapa.Length + " - " + minExercises);
|
|
|
|
for (int i = 0; i < etapa.Length; i++)
|
|
{
|
|
Debug.Log(etapa[i].type);
|
|
if (i >= minExercises)
|
|
{
|
|
if (etapa[i].type == "Mídia")
|
|
{
|
|
Debug.Log("TIPO MIDIA");
|
|
StartCoroutine(api.getVideo(etapa[i].idexercises, true));
|
|
yield return waitFrame;
|
|
//StartCoroutine(api.DownloadFile(links[links.Count - 1], etapa[i].idexercises));
|
|
|
|
while (!api.hasDownloadedVideo(downloadingVideo))
|
|
{
|
|
yield return new WaitForSecondsRealtime(.25f);
|
|
}
|
|
|
|
yield return waitFrame;
|
|
}
|
|
else if (etapa[i].type == "Animação")
|
|
{
|
|
yield return StartCoroutine(DownloadfacesSprites());
|
|
yield return StartCoroutine(api.getAnimacao(etapa[i].idexercises));
|
|
yield return waitFrame;
|
|
}
|
|
else if (etapa[i].type == "Diálogo")
|
|
{
|
|
ChConversations_Controller cc = new ChConversations_Controller();
|
|
yield return StartCoroutine(api.GetAllFeelings());
|
|
yield return StartCoroutine(api.GetConversationDetails(etapa[i].idexercises));
|
|
yield return StartCoroutine(api.DownloadCharConvResources());
|
|
yield return waitFrame;
|
|
}
|
|
else if (etapa[i].type == "ChatTime" || etapa[i].type == "Conversação" || etapa[i].type == "Exercício")
|
|
{
|
|
yield return StartCoroutine(DownloadfacesSprites());
|
|
yield return waitFrame;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
downloadingVideo = "a";
|
|
|
|
etapaPronto++;
|
|
Debug.Log("Pronto++");
|
|
}
|
|
|
|
readAllVideos = true;
|
|
|
|
yield break;
|
|
}
|
|
|
|
IEnumerator instantiateFile()
|
|
{
|
|
bool created = false;
|
|
GameObject objCreate = null;
|
|
while (!created)
|
|
{
|
|
objCreate = Resources.Load<GameObject>("Jogo/Cena01");
|
|
|
|
if (objCreate != null)
|
|
{
|
|
created = true;
|
|
}
|
|
else
|
|
{
|
|
yield return new WaitForSecondsRealtime(1);
|
|
}
|
|
}
|
|
|
|
|
|
GameObject creation = Instantiate(objCreate);
|
|
}
|
|
#endregion
|
|
|
|
public bool ExercicioPronunciaFinalizado = false;
|
|
public void Avancar()
|
|
{
|
|
if ((!inExercise && minExercises < etapa.Length - 1) || inExercise || firstQuestion)
|
|
{
|
|
if (!inExercise)
|
|
{
|
|
StartCoroutine(checkNextStep());
|
|
}
|
|
else
|
|
{
|
|
if ((actualExercise + 1) == questions.Count || infaceExercise)
|
|
{
|
|
if (!ExercicioPronunciaFinalizado)
|
|
{
|
|
ExercicioPronunciaFinalizado = true;
|
|
EndExerciseScreen();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
actualExercise++;
|
|
SpawnNextExercise();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
api.updateStep.finishedclass = 1;
|
|
api.updateStep.continueClass = 0;
|
|
StartCoroutine(api.updateStepClass());
|
|
|
|
SpawnEnd();
|
|
}
|
|
|
|
}
|
|
|
|
public void addanswerdb(string answer)
|
|
{
|
|
api.updateStep.answersdb.Add(answer);
|
|
}
|
|
|
|
public void CompleteGame(int i)
|
|
{
|
|
api.updateStep.notegame = i;
|
|
StartCoroutine(api.launchGames(i, etapa[minExercises].idexercises));
|
|
}
|
|
|
|
public void GlobalchangeofNames(GameObject newObj)
|
|
{
|
|
GameObject objOut = GameObject.Find("2");
|
|
objOut.name = "1";
|
|
|
|
//Pega o objeto para spawnar
|
|
newObj.name = "2";
|
|
newObj.transform.SetParent(transform);
|
|
RectTransform thisRect = newObj.GetComponent<RectTransform>();
|
|
thisRect.localScale = new Vector3(1, 1, 1);
|
|
thisRect.anchoredPosition = rightrect.anchoredPosition;
|
|
}
|
|
|
|
public void CheckLoadScreenNConnection()
|
|
{
|
|
if (load.activeSelf)
|
|
{
|
|
GameObject.Find("WarningConnection").GetComponent<CanvasGroup>().alpha = 1;
|
|
}
|
|
}
|
|
|
|
void SetLoadActive(bool state)
|
|
{
|
|
if (state)
|
|
{
|
|
load.SetActive(true);
|
|
load.transform.SetAsLastSibling();
|
|
|
|
if (weakConnection)
|
|
{
|
|
GameObject.Find("WarningConnection").GetComponent<CanvasGroup>().alpha = 1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
load.SetActive(false);
|
|
}
|
|
}
|
|
|
|
int GetQuantityOfCoins(string tipoEtapa)
|
|
{
|
|
switch (etapa[minExercises].type)
|
|
{
|
|
case "Mídia":
|
|
return 10;
|
|
case "Exercício":
|
|
return 20;
|
|
case "Slide":
|
|
return 5;
|
|
case "Animação":
|
|
return 15;
|
|
case "Conversação":
|
|
return 15;
|
|
case "ChatTime":
|
|
return 10;
|
|
case "Jogo":
|
|
return 15;
|
|
case "Diálogo":
|
|
return 15;
|
|
case "ListenRepeat":
|
|
return 15;
|
|
default:
|
|
return 10;
|
|
}
|
|
}
|
|
|
|
public IEnumerator checkNextStep()
|
|
{
|
|
Debug.Log("OUTRO");
|
|
|
|
Debug.Log(minExercises + " - " + etapaPronto);
|
|
|
|
while (minExercises >= etapaPronto)
|
|
{
|
|
SetLoadActive(true);
|
|
|
|
yield return waitFrame;
|
|
}
|
|
|
|
yield return waitFrame;
|
|
|
|
SetLoadActive(false);
|
|
|
|
yield return waitFrame;
|
|
|
|
if (!firstQuestion)
|
|
{
|
|
Debug.Log("AQ1");
|
|
AddMoreCoins(GetQuantityOfCoins(etapa[minExercises].type));
|
|
minExercises++;
|
|
SetSlider();
|
|
api.changeActualExercises(minExercises);
|
|
api.updateStep.continueClass = 1;
|
|
//StartCoroutine(api.updateStepClass());
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("AQ2");
|
|
firstQuestion = false;
|
|
}
|
|
|
|
Debug.Log("ANTES");
|
|
|
|
switch (etapa[minExercises].type)
|
|
{
|
|
case "Mídia":
|
|
Debug.Log("MIDIA");
|
|
StartCoroutine(SpawnVideo(etapa[minExercises].idexercises, etapa[minExercises].obs));
|
|
break;
|
|
case "Exercício":
|
|
StartCoroutine(api.getExercise(etapa[minExercises].idexercises, false));
|
|
canRetry = true;
|
|
inExercise = true;
|
|
break;
|
|
case "Slide":
|
|
StartCoroutine(api.getSlide(etapa[minExercises].idexercises));
|
|
break;
|
|
case "Animação":
|
|
//StartCoroutine(api.getAnimacao(etapa[minExercises].idexercises));
|
|
StartCoroutine(SpawnAnime(etapa[minExercises].idexercises));
|
|
break;
|
|
case "Conversação":
|
|
StartCoroutine(SpawnConversationFace(etapa[minExercises].idexercises));
|
|
break;
|
|
case "ChatTime":
|
|
StartCoroutine(SpawnConversationFace(etapa[minExercises].idexercises));
|
|
break;
|
|
case "Jogo":
|
|
joojObject.SetActive(true);
|
|
StartCoroutine(SpawnJooj(etapa[minExercises].description, etapa[minExercises].description));
|
|
break;
|
|
case "Diálogo":
|
|
StartCoroutine(SpawnCharactersConversation(etapa[minExercises].idexercises));
|
|
break;
|
|
case "ListenRepeat":
|
|
StartCoroutine(api.getListenRepeat(etapa[minExercises].idexercises));
|
|
break;
|
|
}
|
|
|
|
//StartCoroutine(CheckNUnuseAssets(minExercises - 1));
|
|
}
|
|
|
|
public IEnumerator CheckNUnuseAssets(int nbrEtapa)
|
|
{
|
|
yield return new WaitForSecondsRealtime(1);
|
|
|
|
switch (etapa[nbrEtapa].type)
|
|
{
|
|
case "Mídia":
|
|
string pathToFile = Application.persistentDataPath + "/videoFile_" +
|
|
etapa[nbrEtapa].idexercises + ".mp4";
|
|
if (File.Exists(pathToFile))
|
|
{
|
|
File.Delete(pathToFile);
|
|
}
|
|
break;
|
|
case "ListenRepeat":
|
|
//StartCoroutine(api.getListenRepeat(etapa[minExercises].idexercises));
|
|
break;
|
|
}
|
|
}
|
|
|
|
IEnumerator SpawnCharactersConversation(int idConversation)
|
|
{
|
|
GameObject createObj = Instantiate(Resources.Load<GameObject>("Class/CharactersConversation"));
|
|
|
|
GlobalchangeofNames(createObj);
|
|
|
|
StartCoroutine(waitNShow());
|
|
|
|
yield return new WaitForSecondsRealtime(1);
|
|
|
|
createObj.GetComponent<ChConversations_Controller>().SetInformations(idConversation);
|
|
|
|
yield break;
|
|
}
|
|
|
|
public static string FormatTag(string desc)
|
|
{
|
|
if (desc.IndexOf("<<") < 0)
|
|
{
|
|
return "NULL";
|
|
}
|
|
|
|
string tag = desc.Remove(0, (desc.IndexOf("<<") + 2));
|
|
tag = tag.Remove(tag.IndexOf(">>"));
|
|
|
|
return tag;
|
|
}
|
|
|
|
bool checkGame(string desc)
|
|
{
|
|
return FormatTag(desc) != "NULL";
|
|
}
|
|
|
|
IEnumerator SpawnConversationFace(int conversationtree)
|
|
{
|
|
GameObject Face = Instantiate(Resources.Load<GameObject>("Class/FaceMitsuku"), transform);
|
|
|
|
GlobalchangeofNames(Face);
|
|
|
|
Conversation cv = Face.GetComponent<Conversation>();
|
|
|
|
cv.conversationtree = conversationtree;
|
|
cv.CorpoRequisicao.ChatTimeID = conversationtree;
|
|
cv.CorpoRequisicao.IDAula = etapa[minExercises].idclasses;
|
|
cv.CorpoRequisicao.IDExercicio = etapa[minExercises].idexercises;
|
|
|
|
if (!ReadingFile.StudentUsers.Contains(ReadingFile.instance.userType))
|
|
{
|
|
cv.fakeStart(true);
|
|
}
|
|
else
|
|
{
|
|
cv.fakeStart(false);
|
|
}
|
|
|
|
StartCoroutine(waitNShow());
|
|
|
|
yield break;
|
|
}
|
|
|
|
IEnumerator SpawnJooj(string descGame, string description)
|
|
{
|
|
|
|
if (!checkGame(descGame))
|
|
{
|
|
Avancar();
|
|
yield break;
|
|
}
|
|
|
|
string tag = FormatTag(descGame);
|
|
string infoAddress = "Games/" + tag + "/Info";
|
|
GameObject infoPrefab = null;
|
|
|
|
yield return AddressableGameDownloader.LoadAsset<GameObject>(
|
|
infoAddress,
|
|
result => infoPrefab = result,
|
|
progress => Debug.Log("Preparando aula: " + Mathf.RoundToInt(progress * 100f) + "%"),
|
|
status => Debug.Log(status + " " + infoAddress),
|
|
error => Debug.LogError(error)
|
|
);
|
|
|
|
if (infoPrefab == null)
|
|
{
|
|
Debug.LogError("Jogo Addressable não encontrado: " + infoAddress);
|
|
Avancar();
|
|
yield break;
|
|
}
|
|
|
|
GameInfo info = infoPrefab.GetComponent<GameInfo>();
|
|
GameObject createObj = Instantiate(Resources.Load<GameObject>("Class/GameLoad"));
|
|
GamePage gamePage = createObj.GetComponent<GamePage>();
|
|
gamePage.tagGame = tag;
|
|
gamePage.gameName = description;
|
|
gamePage.SetGameInfo(info);
|
|
|
|
yield return waitFrame;
|
|
|
|
GlobalchangeofNames(createObj);
|
|
StartCoroutine(waitNShow());
|
|
|
|
int rand = Random.Range(0, colorsGroups.Count);
|
|
gamePage.fakeStart(colorsGroups[rand]);
|
|
|
|
yield break;
|
|
}
|
|
|
|
IEnumerator SpawnAnime(int idanimations)
|
|
{
|
|
yield return StartCoroutine(api.getExerciseAnime(etapa[minExercises].idexercises));
|
|
|
|
GameObject createObj = Instantiate(Resources.Load<GameObject>("Class/Animacao"));
|
|
|
|
GlobalchangeofNames(createObj);
|
|
|
|
AnimeControl video = createObj.GetComponent<AnimeControl>();
|
|
StartCoroutine(video.secondStart(idanimations, exercisesAnime));
|
|
|
|
StartCoroutine(waitNShow());
|
|
}
|
|
|
|
public void SpawnSlide(int nbr, int idSlides)
|
|
{
|
|
GameObject createObj = Instantiate(Resources.Load<GameObject>("Class/Slides/Slide"));
|
|
|
|
GlobalchangeofNames(createObj);
|
|
|
|
SlideController slide = createObj.GetComponent<SlideController>();
|
|
int rand = Random.Range(0, colorsGroups.Count);
|
|
StartCoroutine(slide.createImgsCoroutine(nbr, idSlides, colorsGroups[rand]));
|
|
|
|
StartCoroutine(waitNShow());
|
|
}
|
|
|
|
public void SpawnLR(int idLR)
|
|
{
|
|
//StartCoroutine(SpawnLRCoroutine());
|
|
GameObject createObj = Instantiate(Resources.Load<GameObject>("Class/DialogStep/CanvasDialog"));
|
|
GlobalchangeofNames(createObj);
|
|
CreateDialog LR = createObj.GetComponentInChildren<CreateDialog>();
|
|
|
|
StartCoroutine(LR.createDialogTextCoroutine());
|
|
|
|
StartCoroutine(waitNShow());
|
|
}
|
|
|
|
public IEnumerator SpawnVideo(int idmedia, string publishId)
|
|
{
|
|
|
|
GameObject createObj = Instantiate(Resources.Load<GameObject>("Class/Video"));
|
|
//AsyncOperationHandle<GameObject> loadOp = adVideo.InstantiateAsync();
|
|
|
|
GlobalchangeofNames(createObj);
|
|
StartCoroutine(waitNShow());
|
|
|
|
yield return new WaitForSecondsRealtime(1);
|
|
|
|
VideoController video = createObj.GetComponent<VideoController>();
|
|
video.fakeStart(idmedia, publishId);
|
|
|
|
yield return waitFrame;
|
|
}
|
|
|
|
public void LiberarAvanco(bool right)
|
|
{
|
|
avance.SetActive(true);
|
|
}
|
|
|
|
#region Go Out
|
|
List<GameObject> mics = new List<GameObject>();
|
|
public GameObject prefabMic;
|
|
public Sprite micChosenOne, micNotChosenOne;
|
|
|
|
public void SairDaAula()
|
|
{
|
|
|
|
sairAula.SetActive(true);
|
|
}
|
|
|
|
public void ConfirmSair(bool yes)
|
|
{
|
|
if (yes)
|
|
{
|
|
GameObject.Find("Canvas").SetActive(true);
|
|
StartCoroutine(SairAula());
|
|
}
|
|
else
|
|
{
|
|
sairAula.SetActive(false);
|
|
}
|
|
}
|
|
|
|
IEnumerator SairAula()
|
|
{
|
|
Instantiate(Resources.Load<GameObject>("Class/ReturningToMenu"), GameObject.Find("Canvas - GoOut").transform).transform.SetAsLastSibling();
|
|
|
|
yield return waitFrame;
|
|
|
|
api.updateStep.actualexercise = minExercises;
|
|
yield return StartCoroutine(api.updateStepClass());
|
|
|
|
GameControl gameControl = GameControl.instance;
|
|
|
|
if (gameControl.inGame)
|
|
{
|
|
gameControl.SetOriginalCanvasActive();
|
|
StartCoroutine(SairEnquantoEmJogo());
|
|
}
|
|
else
|
|
{
|
|
SceneManager.LoadSceneAsync(0, LoadSceneMode.Single);
|
|
}
|
|
}
|
|
|
|
IEnumerator SairEnquantoEmJogo()
|
|
{
|
|
GameControl control = GameControl.instance;
|
|
GamesResourcesFinder gameResource = control.gameCreate.GetComponentInChildren<GamesResourcesFinder>();
|
|
|
|
if (gameResource != null)
|
|
{
|
|
yield return StartCoroutine(gameResource.EndGame(true, true));
|
|
}
|
|
|
|
yield return waitFrame;
|
|
|
|
SceneManager.LoadSceneAsync(0, LoadSceneMode.Single);
|
|
|
|
yield break;
|
|
}
|
|
#endregion
|
|
|
|
IEnumerator waitNShow()
|
|
{
|
|
avance.SetActive(false);
|
|
|
|
yield return waitFrame;
|
|
yield return waitFrame;
|
|
|
|
thisAnime.Rebind();
|
|
|
|
thisAnime.SetTrigger("change");
|
|
}
|
|
|
|
public void EndClass()
|
|
{
|
|
if (doneLaunchingnotes)
|
|
{
|
|
SceneManager.LoadSceneAsync(0, LoadSceneMode.Single);
|
|
}
|
|
}
|
|
|
|
public void SpawnEnd()
|
|
{
|
|
GameObject createObj = Instantiate(Resources.Load<GameObject>("Class/Ending"));
|
|
|
|
GlobalchangeofNames(createObj);
|
|
|
|
StartCoroutine(waitNShow());
|
|
}
|
|
|
|
#region Show Steps
|
|
public void ShowSteps()
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Conversation Face
|
|
[System.Serializable]
|
|
public class FaceObjects
|
|
{
|
|
public Sprite eyes, cheek, face, glasses;
|
|
}
|
|
|
|
public FaceObjects faceObjects;
|
|
public bool hasdownloadedIitens;
|
|
|
|
public void DownloadImageSprs()
|
|
{
|
|
StartCoroutine(DownloadfacesSprites());
|
|
}
|
|
|
|
IEnumerator DownloadfacesSprites()
|
|
{
|
|
Debug.Log("Baixar Sprites");
|
|
if (!hasdownloadedIitens)
|
|
{
|
|
APICustomize customize = GetComponent<APICustomize>();
|
|
|
|
yield return StartCoroutine(customize.checkItens());
|
|
|
|
string[] itensActual = customize.actualItens.Split(';');
|
|
faceObjects = new FaceObjects();
|
|
|
|
yield return StartCoroutine(DownloadPhoto("eyes", itensActual[0]));
|
|
yield return StartCoroutine(DownloadPhoto("cheek", itensActual[1]));
|
|
yield return StartCoroutine(DownloadPhoto("face", itensActual[2]));
|
|
yield return StartCoroutine(DownloadPhoto("glasses", itensActual[3]));
|
|
|
|
hasdownloadedIitens = true;
|
|
|
|
yield break;
|
|
}
|
|
else
|
|
{
|
|
yield break;
|
|
}
|
|
}
|
|
|
|
IEnumerator DownloadPhoto(string part, string resource)
|
|
{
|
|
if (resource.Contains("_0"))
|
|
{
|
|
SetPartFace(part, null);
|
|
}
|
|
else
|
|
{
|
|
string url = "http://" + ReadingFile.iploc + "/zoeGamesResources/CustomizeZoe/" +
|
|
resource + ".png";
|
|
|
|
Debug.Log(url);
|
|
|
|
using (WWW www = new WWW(url))
|
|
{
|
|
yield return www;
|
|
|
|
Sprite spr = Sprite.Create(www.texture, new Rect(0, 0, www.texture.width, www.texture.height),
|
|
new Vector2(0, 0));
|
|
|
|
SetPartFace(part, spr);
|
|
}
|
|
}
|
|
}
|
|
|
|
void SetPartFace(string part, Sprite value)
|
|
{
|
|
switch (part)
|
|
{
|
|
case "face":
|
|
faceObjects.face = value;
|
|
break;
|
|
case "cheek":
|
|
faceObjects.cheek = value;
|
|
break;
|
|
case "eyes":
|
|
faceObjects.eyes = value;
|
|
break;
|
|
case "glasses":
|
|
faceObjects.glasses = value;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void AddMoreCoins(int coinsToAdd)
|
|
{
|
|
if (completed != 2 && minExercises >= stepstarted)
|
|
{
|
|
StartCoroutine(APICustomize.instance.GiveCoins(coinsToAdd));
|
|
}
|
|
}
|
|
#endregion
|
|
}
|