Exemplo n.º 1
0
    IEnumerator ReadText(string text)
    {
        yield return(new WaitForSeconds(2));

        // execute TTS service with text param and wait for respons
        yield return(StartCoroutine(textToSpeech.SynthesizeText(text, this)));

        RandomizePosition();
        int randomSource = UnityEngine.Random.Range(0, 3);

        audioList.narratorEnter[randomSource].Play();

        isEnteringScene = true;
        isExitingScene  = false;

        // wait for narrator to clear his throat
        yield return(new WaitForSeconds(audioList.narratorEnter[randomSource].clip.length));


        // show text on screen
        if (textToSpeechClip != null)
        {
            audioList.textToSpeechSource.clip = textToSpeechClip;
            if (!audioList.narratorHit.isPlaying)
            {
                audioList.textToSpeechSource.Play();
            }
        }



        uiText.text = text;
        // play audio file

        audioList.AnnounceEnemyDeath();

        yield return(new WaitForSeconds(4 * readSpeed));

        isEnteringScene = false;
        isExitingScene  = true;
        // remove text
        uiText.text = "";
        isRunning   = false;
    }