예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (UnitySphinx.GetSearchModel() == "kws")
        {
            str = UnitySphinx.DequeueString();
            print("listening for keyword");
            if (str != "")
            {
                UnitySphinx.SetSearchModel(UnitySphinx.SearchModel.jsgf);
                //guitext.text = "order up";
                print(str);
            }
        }

        /*
         * else if (UnitySphinx.GetSearchModel() == "jsgf")
         * {
         *  if (str!="")
         *  {
         *      Vector3 v;
         *      if (str == "ALAXA")
         *          v = new Vector3(0, 0.5f, 0);
         *      else if (str == "AYNACHA")
         *          v = new Vector3(0, -0.5f, 0);
         *      else if (str == "KUPI")
         *          v = new Vector3(0.5f, 0, 0);
         *      else v = new Vector3(-0.5f, 0, 0);
         *
         *      transform.position += v;
         *      print("de prueba " + str);
         *  }
         *
         *
         * }*/
    }
예제 #2
0
 void Update()
 {
     str = UnitySphinx.DequeueString();
     if (UnitySphinx.GetSearchModel() == "kws")
     {
         print("listening for keyword");
         if (str != "")
         {
             UnitySphinx.SetSearchModel(UnitySphinx.SearchModel.jsgf);
             guitext.text = "order up";
             print(str);
         }
     }
     else if (UnitySphinx.GetSearchModel() == "jsgf")
     {
         print("listening for order");
         if (str != "")
         {
             guitext.text = str;
             char[]     delimChars = { ' ' };
             string[]   cmd        = str.Split(delimChars);
             int        numAnimals = interpretNum(cmd [0]);
             GameObject animal     = interpretAnimal(cmd [1]);
             for (int i = 0; i < numAnimals; i++)
             {
                 Vector3 randPos =
                     new Vector3(spawn.position.x + UnityEngine.Random.Range(-0.1f, 0.1f),
                                 spawn.position.y + UnityEngine.Random.Range(-0.1f, 0.1f),
                                 spawn.position.z + UnityEngine.Random.Range(-0.1f, 0.1f));
                 Instantiate(animal, randPos, spawn.rotation);
             }
             UnitySphinx.SetSearchModel(UnitySphinx.SearchModel.kws);
         }
     }
 }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        Vector3    fwd = transform.TransformDirection(Vector3.forward);
        RaycastHit Hit;


        if (Physics.Raycast(transform.position, fwd, out Hit, 100f))
        {
            string str         = UnitySphinx.DequeueString();
            bool   morirpuma   = false;
            bool   corrergente = false;
            if (UnitySphinx.GetSearchModel() == "jsgf")
            {
                if (str != "")
                {
                    if (str == "THANTHA TITI")
                    {
                        morirpuma = true;
                    }
                    else if (str == "SINTI TITI")
                    {
                        corrergente = true;
                        pumasmuertos++;
                    }

                    print(str);
                }
            }

            if (Hit.collider.gameObject.tag == "Highlightable" && morirpuma)
            {
                Debug.Log("puma hiteado");
                Hit.collider.gameObject.GetComponent <Perseguir>().Highlighted = true;
                Destroy(Hit.collider.gameObject);
                pumasmuertos++;
                if (pumasmuertos >= 15)
                {
                    SceneManager.LoadScene("Menu");
                }
            }

            if (Hit.collider.gameObject.tag.Equals("Escapador") && corrergente)
            {
                Debug.Log("roboot hiteado");

                Hit.collider.gameObject.GetComponent <Corredor>().Correr = true;
                // Destroy(Hit.collider.gameObject);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        str = UnitySphinx.DequeueString();
        if (UnitySphinx.GetSearchModel() == "kws")
        {
            //print("listening for keyword");
            if (str != "")
            {
                if (str.IndexOf("movement") != -1)
                {
                    UnitySphinx.Stop();
                    jsgf = Application.dataPath + "/Resources/UnitySphinx/model/en-us/movement.gram";
                    UnitySphinx.Init(jsgf, kws);
                    UnitySphinx.Run();
                    UnitySphinx.SetSearchModel(UnitySphinx.SearchModel.jsgf);
                }
                if (str.IndexOf("rotation") != -1)
                {
                    UnitySphinx.Stop();
                    jsgf = Application.dataPath + "/Resources/UnitySphinx/model/en-us/rotation.gram";
                    UnitySphinx.Init(jsgf, kws);
                    UnitySphinx.Run();
                    UnitySphinx.SetSearchModel(UnitySphinx.SearchModel.jsgf);
                }

                print(str);
            }
        }
        else if (UnitySphinx.GetSearchModel() == "jsgf")
        {
            print("listening for order");

            if (str != "")
            {
                if (str.IndexOf("move") != -1)
                {
                    startposition = 0f;
                    if (str.IndexOf("up") != -1)
                    {
                        direction = 1;
                    }
                    else if (str.IndexOf("down") != -1)
                    {
                        direction = -1;
                    }
                    if (str.IndexOf("one") != -1)
                    {
                        meters = 1;
                    }
                    if (str.IndexOf("two") != -1)
                    {
                        meters = 2;
                    }
                    else if (str.IndexOf("three") != -1)
                    {
                        meters = 3;
                    }
                    else if (str.IndexOf("four") != -1)
                    {
                        meters = 4;
                    }
                }

                if (str.IndexOf("rotate") != -1)
                {
                    if (str.IndexOf("right") != -1)
                    {
                        direction = 1;
                    }
                    else if (str.IndexOf("left") != -1)
                    {
                        direction = -1;
                    }
                    if (str.IndexOf("fast") != -1)
                    {
                        velocity = 4;
                    }
                    if (str.IndexOf("slow") != -1)
                    {
                        velocity = 1;
                    }
                }
                if (str.IndexOf("exit") != -1)
                {
                    meters    = 0;
                    direction = 0;
                    velocity  = 0f;
                    UnitySphinx.SetSearchModel(UnitySphinx.SearchModel.kws);
                }
                print(str);
            }

            if (startposition <= meters)
            {
                startposition = startposition + 0.05f;
                transform.Translate(0, 0, direction * 0.05f);
            }
            transform.Rotate(0, 0, direction * velocity * Time.deltaTime * 50);
        }
    }