using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class CckW : MonoBehaviour { public static bool finishedGame = false; public static bool ended = false; int index = 0; private int pointstoWin, currentPoints; private AudioSource audio; private Text enunciado; public AudioClip correct, wrong; public GameObject stage1, stage2, stage3, stage4, stage5; public SpriteRenderer imagem; public List nomes; public List sprites; private Coroutine running; [System.Serializable] public class Sprites { public Sprite Maneqq; } [System.Serializable] public class Nomes { public string Roupa; } void Updadte() { if (currentPoints == pointstoWin) { win(); } } void Start() { int index = 0; ended = false; finishedGame = false; audio = GameObject.Find("Imagem").GetComponent(); imagem = GameObject.Find("Imagem").GetComponent(); enunciado = GameObject.Find("Enunciado").GetComponent(); currentPoints = 0; pointstoWin = 10; GameControl.instance.StartedGame(); } IEnumerator espera(float wait) { yield return new WaitForSeconds(wait); Debug.Log("a"); if (currentPoints == 2) { Destroy(stage1); enunciado.text = nomes[0].Roupa.ToString(); stage2.SetActive(true); } else if (currentPoints == 4) { Destroy(stage2); enunciado.text = nomes[1].Roupa.ToString(); imagem.sprite = sprites[0].Maneqq; stage3.SetActive(true); } else if (currentPoints == 6) { Destroy(stage3); enunciado.text = nomes[2].Roupa.ToString(); stage4.SetActive(true); } else if (currentPoints == 8) { Destroy(stage4); enunciado.text = nomes[3].Roupa.ToString(); stage5.SetActive(true); } else if(currentPoints == pointstoWin) { win(); } running = null; } public void AddPoints() { currentPoints++; Debug.Log(currentPoints); if (running != null) { StopCoroutine(running); running = null; } if (currentPoints == 2) { running = StartCoroutine(espera(2)); } else if (currentPoints == 4) { running = StartCoroutine(espera(2)); } else if (currentPoints == 6) { running = StartCoroutine(espera(2)); } else if(currentPoints == 8) { running = StartCoroutine(espera(2)); } else if (currentPoints == pointstoWin) { running = StartCoroutine(espera(0)); } } void win() { GameControl.instance.FinishGame(); } public void CorrectSound() { audio.clip = correct; audio.Play(); } public void WrongSound() { audio.clip = wrong; audio.Play(); } }