public void AddSpeechEvent(SpeechEvent speech, bool startQueue = false) { speechQueue.Enqueue(speech); if (startQueue) { TryNextSpeechEvent(); } }
void StartSpeechEvent(SpeechEvent speech) { speech.message = keys.ReplaceKeys(speech.message); if (speech.response != null) { for (int i = 0; i < speech.response.choices.Count; i++) { speech.response.choices[i] = keys.ReplaceKeys(speech.response.choices[i]); } } StartCoroutine(TypeText(chatText, speech)); }
private IEnumerator TypeText(Text text, SpeechEvent speech) { responsePanel.SetActive(false); text.text = ""; displayedEmotion = speech.emotion; for (int i = 0; i < speech.message.Length; i++) { if (speech.message[i] != '&') { text.text += speech.message[i]; PlayTextBlip(); } //& acts as a special character for longer pauses else if (!FastTalk) { yield return(new WaitForSeconds(speech.letterPause * 2)); } yield return(0); if (!FastTalk) { yield return(new WaitForSeconds(speech.letterPause)); } if (!FastTalk && (speech.message[i] == '.' || speech.message[i] == '!' || speech.message[i] == '?')) { yield return(new WaitForSeconds(speech.letterPause * 2)); } } speech.message = text.text; if (speech.response == null) { yield return(new WaitForSeconds(FastTalk ? 0.1f : speech.timeUntilNextSpeech)); InGame_Interface.instance.AddLogText(chatName.text, speech.message); FinishedSpeechEvent(speech); } else { string responseContent = ""; for (int i = 0; i < speech.response.choices.Count; i++) { responseContent += string.Format("{0}. {1}\n", i + 1, speech.response.choices[i]); } responseText.text = responseContent; responsePanel.SetActive(true); //Await Input bool awaitingInput = true; while (awaitingInput) { bool[] input = new bool[5]; input[0] = Input.GetKeyDown(KeyCode.Alpha1); input[1] = Input.GetKeyDown(KeyCode.Alpha2); input[2] = Input.GetKeyDown(KeyCode.Alpha3); input[3] = Input.GetKeyDown(KeyCode.Alpha4); input[4] = Input.GetKeyDown(KeyCode.Alpha5); for (int i = 0; i < input.Length; i++) { if (input[i] && speech.response.choices.Count >= i + 1) { awaitingInput = false; InGame_Interface.instance.AddLogText(PlayerData.name, speech.response.choices[i]); EventManager.instance.DialogueEvent(speech.response.choicesEventID[i]); responsePanel.SetActive(false); break; } } yield return(null); } FinishedSpeechEvent(speech); } }
void FinishedSpeechEvent(SpeechEvent speech) { EventManager.instance.FireEvent(speech.eventOnSpeechFinished); isSpeaking = false; TryNextSpeechEvent(); }