// TODO migrar isso para um controlador. // A não ser que seja interessante colocar esse tipo de lógica mais alto nível aqui // (até para evitar mais chamadas de GetComponent(). private IEnumerator TransitionScenes(int fromIndex, int toIndex) { GameObject from = screenManagement.GetScreenAt(fromIndex); GameObject to = screenManagement.GetScreenAt(toIndex); Debug.Log("Starting transition from " + from + " to " + to); screenTransition.BlockInteraction(true); yield return(StartCoroutine(screenTransition.FadeOut())); currentScreenController = to.GetComponent <PointAndClickController>(); // switching scenes //screenManagement.UpdateToNextScreen(); // === TODO mover esse texto para outro lugar caso não seja aqui o seu local ideal itemsSelectedReference.text = ""; itemsSelectedReference.transform.parent.gameObject.SetActive(currentScreenController.Type == PointAndClickType.FindItem); // end todo === screenManagement.SetCurrentScreenIndex(toIndex); from.SetActive(false); to.SetActive(true); // showing new scene yield return(StartCoroutine(screenTransition.FadeIn())); screenTransition.BlockInteraction(false); // yield ; }
private void Awake() { image = GetComponent <Image>(); button = GetComponent <Button>(); // TODO the controller criará a instância desse prefab e passará a si mesmo como parâmetro controller = transform.parent.parent.GetComponent <PointAndClickController>(); if (button) { // button.onClick.RemoveAllListeners(); // button.onClick.AddListener(() => { NotifyManager(); }); } }
private IEnumerator IntroFadeIn() { Debug.Log("Bloqueando a Interação no começo"); screenTransition.BlockInteraction(true); int index = (screenManagement.GetCurrentScreenIndex()); currentScreenController = screenManagement.GetScreenAt(index).GetComponent <PointAndClickController>(); itemsSelectedReference.transform.parent.gameObject.SetActive(currentScreenController.Type == PointAndClickType.FindItem); yield return(StartCoroutine(screenTransition.FadeIn())); Debug.Log("Fade in finished and we're starting the game"); string prefix = (currentScreenController.Type == PointAndClickType.FindItem) ? "Pergunta " : ""; yield return(StartCoroutine(PlayAudio(prefix + currentScreenController.AudioIdentifier))); screenTransition.BlockInteraction(false); Debug.Log("Desbloqueando a Interação no começo"); }