Exemplo n.º 1
0
    IEnumerator songProtocol(bool sadProtocol)
    {
        int numberOfIterations = 0;

        while (true)
        {
            yield return(new WaitForSeconds(ScenesData.songRate_perSecond));

            int numberOfNewWords = microphoneManager.numberOfRecentWords();
            Debug.Log("New words: " + numberOfNewWords);

            if (numberOfNewWords < ScenesData.songRate_numberOfWords)
            {
                continue;
            }

            numberOfIterations++;
            float elapsedTime        = numberOfIterations * ScenesData.songRate_perSecond;
            float percentageComplete = elapsedTime / (sadProtocol ? ScenesData.songDuration * 2 : ScenesData.songDuration);

            if (sadProtocol && percentageComplete < 0.2)
            {
                child.SendMessage("SetNeutralEmotion");
            }

            if (percentageComplete < 0.4)
            {
                setActionScreenText("Great!!! Keep going...");
                child.SendMessage("SetHappyEmotion");
            }
            else if (percentageComplete < 0.7)
            {
                setActionScreenText("Good job, the inner-child is really getting into it!");
                child.SendMessage("SetDanceEmotion");
            }
            else if (percentageComplete >= 1.0)
            {
                songDetected = true;
                AdvanceProtocol();
                break;
            }
        }
    }