private string DetermineGaps(string _text) { speechGaps.Clear(); continueIndex = -1; if (_text != null) { if (_text.Contains("[wait") || _text.Contains("[expression:")) { while (_text.Contains("[wait") || _text.Contains("[expression:")) { int startIndex = _text.IndexOf("[wait"); int expressionIndex = _text.IndexOf("[expression:"); if (speaker != null && expressionIndex >= 0 && (startIndex == -1 || expressionIndex < startIndex)) { // Expression change startIndex = expressionIndex; int endIndex = _text.IndexOf("]", startIndex); string expressionText = _text.Substring(startIndex + 12, endIndex - startIndex - 12); int expressionID = speaker.GetExpressionID(expressionText); speechGaps.Add(new SpeechGap(startIndex, expressionID)); _text = _text.Substring(0, startIndex) + _text.Substring(endIndex + 1); } else if (_text.Substring(startIndex).StartsWith("[wait]")) { // Indefinite wait speechGaps.Add(new SpeechGap(startIndex, true)); _text = _text.Substring(0, startIndex) + _text.Substring(startIndex + 6); } else { // Timed wait int endIndex = _text.IndexOf("]", startIndex); string waitTimeText = _text.Substring(startIndex + 6, endIndex - startIndex - 6); speechGaps.Add(new SpeechGap(startIndex, FloatParse(waitTimeText))); _text = _text.Substring(0, startIndex) + _text.Substring(endIndex + 1); } } } if (_text.Contains("[continue]")) { continueIndex = _text.IndexOf("[continue]"); _text = _text.Replace("[continue]", ""); CorrectPreviousGaps(continueIndex, 10); } else if (_text.Contains("[hold]")) { if (continueIndex == -1) { continueIndex = _text.IndexOf("[hold]"); } _text = _text.Replace("[hold]", ""); holdForever = true; CorrectPreviousGaps(continueIndex, 6); } } // Sort speechGaps if (speechGaps.Count > 1) { speechGaps.Sort(delegate(SpeechGap a, SpeechGap b) { return(a.characterIndex.CompareTo(b.characterIndex)); }); } return(_text); }