Exemplo n.º 1
0
    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);
        }
    }
Exemplo n.º 2
0
    //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);
    }
Exemplo n.º 3
0
    /// <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]);
        }
    }
Exemplo n.º 4
0
 private void Start()
 {
     if (sample != null)
     {
         speechData = sample.speechData;
     }
 }
Exemplo n.º 5
0
    private void SetSpeech(SpeechData speechData)
    {
        var speechText = _providerTexts[speechData.TextID];

        SetText(speechText);
        AddCharacters(speechData.Characters);
    }
Exemplo n.º 6
0
    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);
        }
    }
Exemplo n.º 7
0
        public void SpeechSend(SpeechData data)
        {
            if (data == null)
            {
                return;
            }

            speechService?.Send(data);
        }
Exemplo n.º 8
0
 public SpeechData StopVoice()
 {
     if (Speech != null && Task != null)
     {
         Speech.StopRecording();
         try
         {
             Result = Task.Result;
             return(Result);
         }
         catch { }
     }
     return(null);
 }
Exemplo n.º 9
0
    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());
    }
Exemplo n.º 10
0
 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);
 }
Exemplo n.º 11
0
        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);
            }
        }
Exemplo n.º 12
0
    /// <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);
        }
    }
Exemplo n.º 13
0
    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;
        }
    }
Exemplo n.º 14
0
 public SpeechDataPlayer(string serialized_data)
 {
     _data = SpeechData.Deserialize(serialized_data);
 }
Exemplo n.º 15
0
 public SpeechDataPlayer(SpeechData data)
 {
     _data = data;
 }
Exemplo n.º 16
0
 public SpeechDataPlayerEventArgs(SpeechData data)
 {
     this.speechData = data;
 }
Exemplo n.º 17
0
 public SpeechCharacteristicReachedEventArgs(SpeechData.SpeechCharacteristic characteristic)
 {
     this.characteristic = characteristic;
 }