Example #1
0
        private async void ListenForPatrick()
        {
            IAsyncOperation <SpeechRecognitionResult> recognitionOperation;
            SpeechRecognitionResult speechRecognitionResult;

            while (true)
            {
                if (speechRecognizer != null)
                {
                    recognitionOperation    = speechRecognizer.RecognizeAsync();
                    speechRecognitionResult = await recognitionOperation;

                    if (speechRecognitionResult.Status == SpeechRecognitionResultStatus.Success)
                    {
                        // BUG: Sometimes hits success repetitively and does not listen for input
                        Debug.WriteLine(speechRecognitionResult.Text);
                        if (speechRecognitionResult.Text.Length > 0)
                        {
                            ProcessSpeech(speechRecognitionResult.Text);
                        }
                    }
                }
                else
                {
                    await System.Threading.Tasks.Task.Delay(250);
                }

                Blink.Begin();
            }
        }
    public virtual void Damage(int val)
    {
        if (hp <= 0)
        {
            return;
        }
        AudioManager.GetInstance().PlaySound(damageSound);

        hp -= val;
        animator.SetInteger("hp", hp);
        blink.Begin(0.15f);
        if (hp <= lostHeadHp && hasHead)
        {
            LostHead();
        }
        if (hp <= 0)
        {
            Die();
        }
    }
Example #3
0
        private async void ListenForPatrick()
        {
            IAsyncOperation <SpeechRecognitionResult> recognitionOperation;
            SpeechRecognitionResult speechRecognitionResult;

            while (true)
            {
                recognitionOperation    = speechRecognizer.RecognizeAsync();
                speechRecognitionResult = await recognitionOperation;
                Blink.Begin();
                if (speechRecognitionResult.Status == SpeechRecognitionResultStatus.Success)
                {
                    // BUG: Sometimes hits success repetitively and does not listen for input
                    Debug.WriteLine(speechRecognitionResult.Text);
                    if (speechRecognitionResult.Text.Length > 0)
                    {
                        Speak(await ProcessSpeech(speechRecognitionResult.Text));
                    }
                }
            }
        }