Пример #1
0
    // waits for the player response before looping back into the WaitForClip IEnumerator
    // to play the next recording
    IEnumerator WaitForRecording(float time, int index)
    {
        Debug.Log("waiting for recording...");
        AudioClip recording = Microphone.Start("Built-in Microphone", false, (int)time, SAMPLE_RATE);

        yield return(new WaitForSeconds(time));

        playerRecordings[index] = recording;
        playerLoudness[index]   = AnalyzeLoudness(playerRecordings[index]);

        if (index < CurrentLanguagePrompts.Length - 1)
        {
            StartCoroutine(WaitForClip(CurrentLanguagePrompts[index + 1].length, index + 1));
        }
        else
        {
            float average = GetBaseline();
            if (average > 0.02f)
            {
                print("monster scared");
                monsterController.DoScare();
            }
            else if (average > 0.000001)
            {
                print("monster loved");
                monsterController.DoLove();
            }
            Constants.phoneCallOver = true;
        }
    }