/* <summary> * The function shows the sequence of lights (cubes) on the frontal plane * </summary> * * <param name="sequence"> sequence is an array of numbers representing the light sequence </param> * <remarks> sequence must contain the number of cubes and NOT as indexes </remarks> * <param name="plane"> plane is the GameObject reference to the plane where the cubes are </param> */ private IEnumerator LightCoroutine(int[] sequence, GameObject plane) { GameObject frontalCube; panelMessage.SetActive(true); //Showing the Starting Panel if (MagicOrchestraParameters.IsContext) { frontalTextMessage.GetComponent <Text>().text = MagicOrchestraUtils.beginCorsiSequenceMessage_context; frontalTextMessage.GetComponent <AudioSource>().clip = Resources.Load <AudioClip>(MagicOrchestraUtils.pathToTextMessages + "beginCorsiSequenceMessage_context"); frontalTextMessage.GetComponent <AudioSource>().Play(); } else { frontalTextMessage.GetComponent <Text>().text = MagicOrchestraUtils.beginCorsiSequenceMessage; frontalTextMessage.GetComponent <AudioSource>().clip = Resources.Load <AudioClip>(MagicOrchestraUtils.pathToTextMessages + "beginCorsiSequenceMessage"); frontalTextMessage.GetComponent <AudioSource>().Play(); } yield return(new WaitForSeconds(MagicOrchestraUtils.generalTextTimeShow_long)); panelMessage.SetActive(false); frontalTextMessage.GetComponent <Text>().text = ""; yield return(new WaitForSeconds(MagicOrchestraUtils.generalPauseTime_short)); //Looping on the sequence foreach (int number in sequence) { if (number >= 1 && number <= 9) { //Retriving the frontal cube frontalCube = plane.transform.GetChild(number - 1).gameObject.transform.GetChild(0).gameObject; //Turn on the light CorsiUtils.ShowLightOnCube(frontalCube, SequenceUser.singleton.lightMaterial); yield return(new WaitForSeconds(this.showTime)); //Turn off the light CorsiUtils.RestoreIntialCube(frontalCube, SequenceUser.singleton.defaultMaterial); } } ////Showing the User turn Panel //foreach( GameObject go in userTurnPanel) //{ // go.SetActive(true); //} //yield return new WaitForSeconds(MagicOrchestraUtils.generalTextTimeShow_short); //foreach (GameObject go in userTurnPanel) //{ // go.SetActive(false); //} CorsiController.singleton.EndFrontalPhase(); StopCoroutine(this.lightCoroutine); }
/* <summary> * OnTriggerExit is called when the player exits from the cube and destroy the timer * </summary> */ private void OnTriggerExit(Collider other) { //Reset the timer this.timer = 0; //Reset the color CorsiUtils.RestoreIntialCube(this.gameObject, SequenceUser.singleton.defaultMaterial); //Informing the SequenceUser of the current position SequenceUser.singleton.DeleteCurrentCube(); }
private IEnumerator LightCoroutine(GameObject cubeToLight, bool isFinal, bool isSequenceCorrect) { //Turn on the light CorsiUtils.ShowLightOnCube(cubeToLight, lightMaterial); yield return(new WaitForSeconds(CorsiUtils.reactionLightTime)); //Turn off the light CorsiUtils.RestoreIntialCube(cubeToLight, defaultMaterial); //Final cube detected if (isFinal) { float waitTime = MagicOrchestraUtils.generalTextTimeShow_long; //Recalling game manager if (isSequenceCorrect) { panelMessage.SetActive(true); // Message frontalTextMessage.GetComponent <Text>().text = MagicOrchestraUtils.correctSequenceMessage; // Light feedback MagicOrchestraUtils.PositiveLightFeedback(); // First sound if (MagicOrchestraParameters.IsContext) { frontalTextMessage.GetComponent <AudioSource>().clip = Resources.Load <AudioClip>(MagicOrchestraUtils.pathToSoundMessages + "sequence_correct_context"); } else { frontalTextMessage.GetComponent <AudioSource>().clip = Resources.Load <AudioClip>(MagicOrchestraUtils.pathToSoundMessages + "sequence_correct"); } frontalTextMessage.GetComponent <AudioSource>().Play(); waitTime -= frontalTextMessage.GetComponent <AudioSource>().clip.length; yield return(new WaitForSeconds(frontalTextMessage.GetComponent <AudioSource>().clip.length)); // Second sound frontalTextMessage.GetComponent <AudioSource>().clip = Resources.Load <AudioClip>(MagicOrchestraUtils.pathToTextMessages + "correctSequenceMessage"); frontalTextMessage.GetComponent <AudioSource>().Play(); waitTime -= frontalTextMessage.GetComponent <AudioSource>().clip.length; yield return(new WaitForSeconds(frontalTextMessage.GetComponent <AudioSource>().clip.length)); yield return(new WaitForSeconds(waitTime)); panelMessage.SetActive(false); frontalTextMessage.GetComponent <Text>().text = ""; yield return(new WaitForSeconds(MagicOrchestraUtils.generalPauseTime_short)); MagicOrchestraUtils.SwitchOffLightFeedback(); CorsiController.singleton.CorrectUserSequence(); } else { panelMessage.SetActive(true); // Message frontalTextMessage.GetComponent <Text>().text = MagicOrchestraUtils.wrongSequenceMessage; // Light feedback MagicOrchestraUtils.NegativeLightFeedback(); // First sound frontalTextMessage.GetComponent <AudioSource>().clip = Resources.Load <AudioClip>(MagicOrchestraUtils.pathToSoundMessages + "sequence_wrong"); frontalTextMessage.GetComponent <AudioSource>().Play(); waitTime -= frontalTextMessage.GetComponent <AudioSource>().clip.length; yield return(new WaitForSeconds(frontalTextMessage.GetComponent <AudioSource>().clip.length)); // Second sound frontalTextMessage.GetComponent <AudioSource>().clip = Resources.Load <AudioClip>(MagicOrchestraUtils.pathToTextMessages + "wrongSequenceMessage"); frontalTextMessage.GetComponent <AudioSource>().Play(); waitTime -= frontalTextMessage.GetComponent <AudioSource>().clip.length; yield return(new WaitForSeconds(frontalTextMessage.GetComponent <AudioSource>().clip.length)); yield return(new WaitForSeconds(waitTime)); panelMessage.SetActive(false); frontalTextMessage.GetComponent <Text>().text = ""; yield return(new WaitForSeconds(MagicOrchestraUtils.generalPauseTime_short)); MagicOrchestraUtils.SwitchOffLightFeedback(); CorsiController.singleton.WrongUserSequence(); } } //Abort coroutine StopClassCoroutine(); }