Example #1
0
    IEnumerator wrongAnswerCoroutine()
    {
        MagicOrchestraUtils.NegativeLightFeedback();
        float waitTime = 0.5f;

        if (Game1Parameters.ConfirmSound)
        {
            this.gameObject.GetComponent <AudioSource>().clip = Resources.Load <AudioClip>(MagicOrchestraUtils.pathToSoundMessages + "wrong");
            this.gameObject.GetComponent <AudioSource>().Play();
            waitTime = this.gameObject.GetComponent <AudioSource>().clip.length;
        }
        yield return(new WaitForSeconds(waitTime));

        MagicOrchestraUtils.SwitchOffLightFeedback();
    }
    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();
    }
Example #3
0
    private IEnumerator FinalCoroutine(bool hasWin)
    {
        panelMessage.SetActive(true);

        float waitTime = MagicOrchestraUtils.generalTextTimeShow_long;

        //Showing user turn information
        if (hasWin)
        {
            // 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));
        }
        else
        {
            // 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();

        //Recalling correct function
        if (hasWin)
        {
            Game2Controller.singleton.CorrectUserSequence();
        }
        else
        {
            Game2Controller.singleton.WrongUserSequence();
        }

        //this.StopClassCoroutine();
    }