private IEnumerator WaitForKeywordManager() { while (!KeywordManager.Instance) { yield return(0); } m_CommandsAdded = true; for (int index = 0; index < m_Commands.Length; index++) { SpeechData command = m_Commands[index]; command.m_Callback = delegate(KeywordRecognizedEventArgs args) { command.m_Target.SendMessage(command.m_Message, null, SendMessageOptions.DontRequireReceiver); }; KeywordManager.Instance.AddKeyword(m_Commands[index].m_SpeechCommand, command.m_Callback, m_RawConfidence); } for (int index = 0; index < m_ExtraCommands.Count; index++) { SpeechData command = m_ExtraCommands[index]; command.m_Callback = delegate(KeywordRecognizedEventArgs args) { command.m_Target.SendMessage(command.m_Message, null, SendMessageOptions.DontRequireReceiver); }; KeywordManager.Instance.AddKeyword(command.m_SpeechCommand, command.m_Callback, m_RawConfidence); } }
//private void Start() //{ // CreateBubble(testData, Vector2.up * 1, TestPlayerCtrl.instance.transform); //} public void CreateBubble(SpeechData speechData, Vector3 localPosition, SpeechBubble.Calback _callback, Transform parent = null) { SpeechBubble newBubble = Instantiate(bubble, parent); newBubble.transform.localPosition = localPosition; newBubble.SetInformation(speechData, bubbleOpenSpeed, bubbleCloseSpeed, textFadeSpeed, _callback); }
/// <summary> /// Removes all extra commands that has the target object, speechCommand and message. /// </summary> /// <param name="target"></param> /// <param name="speechCommand"></param> /// <param name="message"></param> public void RemoveExtraCommand(GameObject target, string speechCommand, string message) { SpeechData data = new SpeechData(); data.m_Message = message; data.m_SpeechCommand = speechCommand; data.m_Target = target; List <SpeechData> commandsToRemove = new List <SpeechData>(); for (int index = 0; index < m_ExtraCommands.Count; index++) { if (data.Equals(m_ExtraCommands[index])) { commandsToRemove.Add(m_ExtraCommands[index]); if (m_CommandsAdded) { KeywordManager.Instance.RemoveKeyword(m_ExtraCommands[index].m_SpeechCommand, m_ExtraCommands[index].m_Callback); } } } for (int index = 0; index < commandsToRemove.Count; index++) { m_ExtraCommands.Remove(commandsToRemove[index]); } }
private void Start() { if (sample != null) { speechData = sample.speechData; } }
private void SetSpeech(SpeechData speechData) { var speechText = _providerTexts[speechData.TextID]; SetText(speechText); AddCharacters(speechData.Characters); }
void ShowDialogue() { speechDisplay.SetActive(true); SpeechData speechData = currentChapterData.dialogues[currentSequenceData.idNumber].speeches[speechIndex]; // Get the QuestionData for the current question speechText.text = speechData.speechText; characterLeft.speakTail.gameObject.SetActive(false); characterLeft.thinkTail.gameObject.SetActive(false); characterRight.speakTail.gameObject.SetActive(false); characterRight.thinkTail.gameObject.SetActive(false); characterLeft1.speakTail.gameObject.SetActive(false); characterLeft1.thinkTail.gameObject.SetActive(false); if (speechData.speakingCharacterId == characterLeft.data.idText) { // Left character is speaking characterLeft.speakTail.gameObject.SetActive(true); } else if (speechData.speakingCharacterId == characterRight.data.idText) { // Right character is speaking characterRight.speakTail.gameObject.SetActive(true); } else if (speechData.speakingCharacterId == characterLeft1.data.idText) { // Left character is speaking characterLeft1.speakTail.gameObject.SetActive(true); } }
public void SpeechSend(SpeechData data) { if (data == null) { return; } speechService?.Send(data); }
public SpeechData StopVoice() { if (Speech != null && Task != null) { Speech.StopRecording(); try { Result = Task.Result; return(Result); } catch { } } return(null); }
public void SetInformation(SpeechData speechData, float openSpeed, float closeSpeed, float textFadeSpeed, Calback _callback) { WordData[] firstLineText, secondLineText; speechData.CreateScript(out firstLineText, out secondLineText, out hasSecondLine); this.textFadeSpeed = textFadeSpeed; this.speechData = speechData; this.callback = _callback; bubbleOpenSpeed = openSpeed; bubbleCloseSpeed = closeSpeed; parts = new Transform[transform.childCount]; int j; for (j = 0; j < transform.childCount - 1; j++) { parts[j] = transform.GetChild(j); if (speechData.partSprite[j]) { parts[j].GetComponent <SpriteRenderer>().sprite = speechData.partSprite[j]; } } parts[j] = transform.GetChild(j); for (int i = 0; i < firstLineText.Length; i++) { firstLineQueue.Enqueue(firstLineText[i]); } for (int i = 0; i < secondLineText.Length; i++) { secondLineQueue.Enqueue(secondLineText[i]); } if (!hasSecondLine) { bubbleWidth = firstLineText.Length * speechData.wordSize.x; bubbleHeight = speechData.wordSize.y + speechData.padding.y + speechData.padding.w; } else { bubbleWidth = (firstLineText.Length > secondLineText.Length) ? firstLineText.Length : secondLineText.Length; bubbleWidth *= speechData.wordSize.x; bubbleHeight = speechData.wordSize.y * 2 + speechData.lineSpacing + speechData.padding.y + speechData.padding.w; } StartCoroutine(ShowAnim()); }
public SpeechData GetSpeech(int id) { for (int i = 0; i < Speeches.Count; i++) { if (Speeches[i].Id == id) { SpeechData speech = new SpeechData() { Id = Speeches[i].Id, Text = Speeches[i].Text }; return(speech); } } Debug.LogWarning("Cant find speech with id " + id); return(null); }
public AsciiSpeechPacket(MessageTypes type, int font, int hue, string lang, string text) : base(0xAD, "Ascii Speech") { // get triggers int triggerCount; int[] triggers; SpeechData.GetSpeechTriggers(text, lang, out triggerCount, out triggers); if (triggerCount > 0) { type = (MessageTypes)(type | MessageTypes.EncodedTriggers); } Stream.Write((byte)type); Stream.Write((short)hue); Stream.Write((short)font); Stream.WriteAsciiNull(lang); if (triggerCount > 0) { byte[] t = new byte[(int)Math.Ceiling((triggerCount + 1) * 1.5f)]; // write 12 bits at a time. first write count: byte then half byte. t[0] = (byte)((triggerCount & 0x0FF0) >> 4); t[1] = (byte)((triggerCount & 0x000F) << 4); for (int i = 0; i < triggerCount; i++) { int index = (int)((i + 1) * 1.5f); if (i % 2 == 0) // write half byte and then byte { t[index + 0] |= (byte)((triggers[i] & 0x0F00) >> 8); t[index + 1] = (byte)(triggers[i] & 0x00FF); } else // write byte and then half byte { t[index] = (byte)((triggers[i] & 0x0FF0) >> 4); t[index + 1] = (byte)((triggers[i] & 0x000F) << 4); } } Stream.BaseStream.Write(t, 0, t.Length); Stream.WriteAsciiNull(text); } else { Stream.WriteBigUniNull(text); } }
/// <summary> /// Adds an extra command that sends message to the target object when speechCommand is said. /// </summary> /// <param name="target"></param> /// <param name="speechCommand"></param> /// <param name="message"></param> /// <param name="code">Key code to press to trigger the command while in the editor.</param> public void AddExtraCommand(GameObject target, string speechCommand, string message, KeyCode code = KeyCode.None) { SpeechData data = new SpeechData(); data.m_Message = message; data.m_SpeechCommand = speechCommand; data.m_Target = target; data.m_DebugKeyCode = code; m_ExtraCommands.Add(data); if (m_CommandsAdded) { data.m_Callback = delegate(KeywordRecognizedEventArgs args) { data.m_Target.SendMessage(data.m_Message, null, SendMessageOptions.DontRequireReceiver); }; KeywordManager.Instance.AddKeyword(data.m_SpeechCommand, data.m_Callback, m_RawConfidence); } }
void ShowSpeechBubble(SpeechData data) { switch (data.type) { case SpeechType.Pet: if (!petObject.activeInHierarchy) { petObject.SetActive(true); } petText.text = data.text; break; case SpeechType.Player: if (!playerObject.activeInHierarchy) { playerObject.SetActive(true); } playerText.text = data.text; break; } }
public SpeechDataPlayer(string serialized_data) { _data = SpeechData.Deserialize(serialized_data); }
public SpeechDataPlayer(SpeechData data) { _data = data; }
public SpeechDataPlayerEventArgs(SpeechData data) { this.speechData = data; }
public SpeechCharacteristicReachedEventArgs(SpeechData.SpeechCharacteristic characteristic) { this.characteristic = characteristic; }