Beispiel #1
0
        private async void Ellipse_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            lock (SyncRootProvider.SyncRoot)
            {
                if (IsRecognizing)
                {
                    return;
                }
                IsRecognizing = true;
            }

            AudioPlay.Stop();

            StatusText.Visibility       = Visibility.Collapsed;
            ListeningDisplay.Visibility = Visibility.Visible;

            string RecResult = await WindowsLocalRecognizeAsync();

            if (RecResult == null)
            {
                IsRecognizing = false;
                return;
            }
            if (RecResult == "Failure")
            {
                ListeningDisplay.Visibility = Visibility.Collapsed;
                StatusText.Visibility       = Visibility.Visible;
                StatusText.Text             = "麦克风未检测到声音输入";
            }
            else
            {
                ListeningDisplay.Visibility = Visibility.Collapsed;
                StatusText.Visibility       = Visibility.Visible;
                StatusText.Text             = RecResult;
            }

            SpeechSynthesisStream stream = await SpeechSynth.SynthesizeTextToStreamAsync(StatusText.Text);

            AudioPlay.SetSource(stream, stream.ContentType);
            AudioPlay.Play();

            IsRecognizing = false;
        }
Beispiel #2
0
    void Update()
    {
        if (Game.me.loading || dead || !sprite.enabled)
        {
            return;
        }
        if (updateCollisions)
        {
            //se receber update do Collide(), atualizar e desligar a variável
            UpdateCollisions();
            updateCollisions = false;
        }
        highnessUpdate = false;
        if (highnessFloat > 1)
        {
            highnessFloat -= Time.deltaTime / 16f;
            if (highnessFloat < 1)
            {
                highnessFloat = 1;
            }
            int i = Mathf.CeilToInt(highnessFloat);
            if (highness != i)
            {
                highness       = i;
                highnessUpdate = true;
                UpdateHighness();
            }
        }
        if (grounded)
        {
            //caso esteja no chão
            if (!customForce && highness > 0 && jumpTempo == 0 && Input.GetButton("jump"))
            {
                //recebe input e pula dependendo da highness da ovelha
                switch (highness)
                {
                case 1: rb.AddForce(new Vector2(0, 6.4f), ForceMode2D.Impulse); break;

                case 2: rb.AddForce(new Vector2(0, 9), ForceMode2D.Impulse); break;

                case 3: rb.AddForce(new Vector2(0, 11), ForceMode2D.Impulse); break;
                }
                jumpTempo   = .125f;
                grounded    = false;
                colAttached = null;
                aud.Play();
                anim.SetBool("jumping", true);
                anim.SetBool("falling", false);
            }
            else
            {
                anim.SetBool("jumping", false);
                anim.SetBool("falling", false);
            }
            velDelta  = 8;
            stopDelta = 4;
        }
        else
        {
            //caso contrário
            velDelta  = 3;
            stopDelta = 1;
            if (rb.velocity.y < 0)
            {
                anim.SetBool("jumping", false);
                anim.SetBool("falling", true);
            }
            else
            {
                anim.SetBool("jumping", true);
                anim.SetBool("falling", false);
            }
        }
        if (jumpTempo > 0)
        {
            jumpTempo -= Time.deltaTime;
            if (jumpTempo < 0)
            {
                jumpTempo = 0;
            }
        }
        //altera a velocidade da ovelha de acordo com o input
        int walk = (int)Input.GetAxisRaw("horizontal");

        if (walk != 0)
        {
            facing = walk;
            if (walk == 1)
            {
                if (spriteTr.localScale.x < 0)
                {
                    spriteTr.localScale = new Vector3(-spriteTr.localScale.x, spriteTr.localScale.y, spriteTr.localScale.z);
                }
                if (velocity < 1)
                {
                    velocity += Time.deltaTime * velDelta;
                    if (velocity > 1)
                    {
                        velocity = 1;
                    }
                }
            }
            else
            {
                if (spriteTr.localScale.x > 0)
                {
                    spriteTr.localScale = new Vector3(-spriteTr.localScale.x, spriteTr.localScale.y, spriteTr.localScale.z);
                }
                if (velocity > -1)
                {
                    velocity -= Time.deltaTime * velDelta;
                    if (velocity < -1)
                    {
                        velocity = -1;
                    }
                }
            }
            anim.SetBool("walking", true);
            anim.SetBool("balancing", false);
        }
        else
        {
            if (velocity != 0)
            {
                if (velocity > 0)
                {
                    velocity -= Time.deltaTime * stopDelta;
                    if (velocity < 0)
                    {
                        velocity = 0;
                    }
                }
                else
                {
                    velocity += Time.deltaTime * stopDelta;
                    if (velocity > 0)
                    {
                        velocity = 0;
                    }
                }
            }
            anim.SetBool("walking", false);
            anim.SetBool("balancing", groundMode > 0);
        }
        if (tr.localPosition.y >= 5)
        {
            arrow.enabled         = true;
            arrowTr.localPosition = new Vector3(0, 4.5f - tr.localPosition.y, 0);
        }
        else
        {
            arrow.enabled = false;
        }
    }