IEnumerator Presenting()
        {
            runsThisFrame = 0;

            lineProcessor.ProcessLine(speech.SpeechText);
            CurrentText = preppendText;

            foreach (var segment in lineProcessor.Segments)
            {
                if (segment.IsTag)
                {
                    CurrentText += segment.DisplayText;
                }
                else
                {
                    foreach (char letter in segment.DisplayText.ToCharArray())
                    {
                        bool isDone = DisplaySegmentLetter(letter);
                        if (isDone)
                        {
                            float waitTime = skip ? 0.01f : 0.01f * speech.SpeechSettings.DisplaySpeed;
                            yield return(new WaitForSeconds(waitTime));
                        }
                    }
                }
            }
            presenting = null;
        }
Beispiel #2
0
        //////////////////////////////////////////////////////////////
        /// <summary>
        ///   This method is used to process the file.  For each line,
        ///   the ILineProcessor.ProcessLine method is called.
        /// </summary>
        /// <param name="lp">the line processor</param>
        /// <exception class="System.IO.IOException">if there is an
        /// error reading the file</exception>
        //////////////////////////////////////////////////////////////

        public void ProcessFile(ILineProcessor lp)
        {
            StreamReader reader = null;

            if (!File.Exists(_filename))
            {
                throw new FileNotFoundException(_filename);
            }

            try
            {
                if (_encoding != null)
                {
                    reader = new StreamReader(_filename,
                                              Encoding.GetEncoding(_encoding));
                }
                else
                {
                    reader = new StreamReader(_filename);
                }

                lp.Reset();
                string line = reader.ReadLine();
                while (line != null)
                {
                    lp.ProcessLine(line);
                    line = reader.ReadLine();
                }
            }
            finally
            {
                try
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                }
                catch (IOException)
                {
                    // don't care
                }
            }
        }