コード例 #1
0
ファイル: MundoController.cs プロジェクト: andresggcf/envi
 private void Update()
 {
     if (gestureListener)
     {
         if (gestureListener.IsSwipeLeft())
         {
             Debug.Log("Left");
             //sLeft();
             //this.transform.RotateAround(cubeman.transform.position, new Vector3(0.0f, -90.0f, 0.0f), Time.deltaTime * smooth);
             //this.transform.RotateAround(cubeman.transform.position, Vector3.up, -180 * Time.deltaTime);
         }
         else if (gestureListener.IsSwipeRight())
         {
             Debug.Log("Right");
             // sRight();
             //this.transform.RotateAround(cubeman.transform.position, new Vector3(0.0f,90.0f,0.0f), Time.deltaTime * smooth);
             //this.transform.RotateAround(cubeman.transform.position, Vector3.up, -180 * Time.deltaTime);
         }
         else if (gestureListener.IsPush())
         {
             Debug.Log("Push");
             //sPush();
         }
         else if (gestureListener.IsPull())
         {
             Debug.Log("Pull");
             //sPull();
         }
     }
     this.transform.rotation = Quaternion.Slerp(this.transform.rotation, mundoObjetivo.transform.rotation, Time.deltaTime * smooth);
     this.transform.position = Vector3.Lerp(this.transform.position, mundoObjetivo.transform.position, Time.deltaTime * smooth);
 }
コード例 #2
0
    private void Update()
    {
        KinectManager manager = KinectManager.Instance;

        if ((!manager || !manager.IsInitialized() || !manager.IsUserDetected()))
        {
            return;
        }

        int iJointIndex = (int)TrackedJoint;

        if (manager.IsUserDetected())
        {
            uint userId = manager.GetPlayer1ID();

            if (manager.IsJointTracked(userId, iJointIndex))
            {
                Vector3 posJoint = manager.GetRawSkeletonJointPos(userId, iJointIndex);
                if (posJoint != Vector3.zero)
                {
                    if (posJoint.x <= rangMax && posJoint.x >= rangMin)
                    {
                        if (gestureListener.IsSwipeLeft())
                        {
                            ActivarMov();
                        }
                        else if (gestureListener.IsSwipeRight())
                        {
                            ActivarMov();
                        }
                    }

                    else
                    {
                        DesactivarMov();
                    }
                }
            }
        }
    }
コード例 #3
0
    void Update()
    {
        KinectManager kinectManager = KinectManager.Instance;

        if ((!kinectManager || !kinectManager.IsInitialized() || !kinectManager.IsUserDetected()))
        {
            return;
        }

        int iJointIndex = (int)TrackedJoint;

        if (kinectManager.IsUserDetected())
        {
            uint userId = kinectManager.GetPlayer1ID();

            if (kinectManager.IsJointTracked(userId, iJointIndex))
            {
                Vector3 posJoint = kinectManager.GetRawSkeletonJointPos(userId, iJointIndex);
                if (posJoint != Vector3.zero)
                {
                    if (!isSpinning)
                    {
                        if (slideChangeWithGestures && gestureListener)
                        {
                            if (activar)
                            {
                                if (posJoint.x <= rangMax && posJoint.x >= rangMin)
                                {
                                    if (!rellotgeActiu)
                                    {
                                        Debug.Log("hola wave");

                                        if (plantesB)
                                        {
                                            fuenteAudio.clip = plantes;
                                            fuenteAudio.Play();
                                            plantesB = false;
                                            volB     = false;
                                            one      = true;
                                        }

                                        rellotgeActiu = true;
                                        activar       = false;
                                    }
                                }
                            }

                            if (!activar)
                            {
                                if (gestureListener.IsWave())
                                {
                                    if (temps >= 5f)
                                    {
                                        Debug.Log("hola swipeUp");
                                        if (rellotgeActiu)
                                        {
                                            speedRotationBase = speedRotation;

                                            for (int i = 0; i <= 10; i++)
                                            {
                                                speedRotation = 600;
                                                MovimentCuca();

                                                if (i == 10)
                                                {
                                                    speedRotation = speedRotationBase;
                                                    MovimentCuca();
                                                }
                                            }

                                            if (one)
                                            {
                                                tocs++; //això només ha de passar una vegada
                                                volB = true;
                                                //plantesB = true; //POSAR AIXÒ QUAN FINALITZA EL GEST
                                                one = false;
                                            }

                                            if (volB)
                                            {
                                                fuenteAudio.clip = vol;
                                                fuenteAudio.Play();
                                                volB = false;
                                                one  = true;
                                            }
                                        }
                                    }
                                }

                                if (gestureListener.IsSwipeUp())
                                {
                                    if (temps >= 5f)
                                    {
                                        Debug.Log("hola swipeUp");
                                        if (rellotgeActiu)
                                        {
                                            speedRotationBase = speedRotation;

                                            for (int i = 0; i <= 10; i++)
                                            {
                                                speedRotation = 600;
                                                MovimentCuca();

                                                if (i == 10)
                                                {
                                                    speedRotation = speedRotationBase;
                                                    MovimentCuca();
                                                }
                                            }

                                            if (one)
                                            {
                                                tocs++; //això només ha de passar una vegada
                                                volB = true;
                                                //plantesB = true; //POSAR AIXÒ QUAN FINALITZA EL GEST
                                                one = false;
                                            }

                                            if (volB)
                                            {
                                                fuenteAudio.clip = vol;
                                                fuenteAudio.Play();
                                                volB = false;
                                                one  = true;
                                            }
                                        }
                                    }
                                }
                                if (gestureListener.IsSwipeLeft())
                                {
                                    if (temps >= 5f)
                                    {
                                        Debug.Log("hola swipeUp");
                                        if (rellotgeActiu)
                                        {
                                            speedRotationBase = speedRotation;

                                            for (int i = 0; i <= 10; i++)
                                            {
                                                speedRotation = 600;
                                                MovimentCuca();

                                                if (i == 10)
                                                {
                                                    speedRotation = speedRotationBase;
                                                    MovimentCuca();
                                                }
                                            }

                                            if (one)
                                            {
                                                tocs++; //això només ha de passar una vegada
                                                volB = true;
                                                //plantesB = true; //POSAR AIXÒ QUAN FINALITZA EL GEST
                                                one = false;
                                            }

                                            if (volB)
                                            {
                                                fuenteAudio.clip = vol;
                                                fuenteAudio.Play();
                                                volB = false;
                                                one  = true;
                                            }
                                        }
                                    }
                                }
                                if (gestureListener.IsSwipeRight())
                                {
                                    if (temps >= 5f)
                                    {
                                        Debug.Log("hola swipeUp");
                                        if (rellotgeActiu)
                                        {
                                            speedRotationBase = speedRotation;

                                            for (int i = 0; i <= 10; i++)
                                            {
                                                speedRotation = 600;
                                                MovimentCuca();

                                                if (i == 10)
                                                {
                                                    speedRotation = speedRotationBase;
                                                    MovimentCuca();
                                                }
                                            }

                                            if (one)
                                            {
                                                tocs++; //això només ha de passar una vegada
                                                volB = true;
                                                //plantesB = true; //POSAR AIXÒ QUAN FINALITZA EL GEST
                                                one = false;
                                            }

                                            if (volB)
                                            {
                                                fuenteAudio.clip = vol;
                                                fuenteAudio.Play();
                                                volB = false;
                                                one  = true;
                                            }
                                        }
                                    }
                                }
                                if (gestureListener.IsWave2())
                                {
                                    if (temps >= 5f)
                                    {
                                        Debug.Log("hola swipeUp");
                                        if (rellotgeActiu)
                                        {
                                            speedRotationBase = speedRotation;

                                            for (int i = 0; i <= 10; i++)
                                            {
                                                speedRotation = 600;
                                                MovimentCuca();

                                                if (i == 10)
                                                {
                                                    speedRotation = speedRotationBase;
                                                    MovimentCuca();
                                                }
                                            }

                                            if (one)
                                            {
                                                tocs++; //això només ha de passar una vegada
                                                volB = true;
                                                //plantesB = true; //POSAR AIXÒ QUAN FINALITZA EL GEST
                                                one = false;
                                            }

                                            if (volB)
                                            {
                                                fuenteAudio.clip = vol;
                                                fuenteAudio.Play();
                                                volB = false;
                                                one  = true;
                                            }
                                        }
                                    }
                                }

                                if (gestureListener.IsTpose())
                                {
                                    if (temps >= 5f)
                                    {
                                        Debug.Log("hola swipeUp");
                                        if (rellotgeActiu)
                                        {
                                            speedRotationBase = speedRotation;

                                            for (int i = 0; i <= 10; i++)
                                            {
                                                speedRotation = 600;
                                                MovimentCuca();

                                                if (i == 10)
                                                {
                                                    speedRotation = speedRotationBase;
                                                    MovimentCuca();
                                                }
                                            }

                                            if (one)
                                            {
                                                tocs++; //això només ha de passar una vegada
                                                volB = true;
                                                //plantesB = true; //POSAR AIXÒ QUAN FINALITZA EL GEST
                                                one = false;
                                            }

                                            if (volB)
                                            {
                                                fuenteAudio.clip = vol;
                                                fuenteAudio.Play();
                                                volB = false;
                                                one  = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }



        if (volar)
        {
            if (rellotgeActiu)
            {
                temps += Time.deltaTime;

                if (temps <= 0f)
                {
                    // Debug.Log("Cuca quieta");
                }

                if (temps > 0f && temps <= 11f)
                {
                    radiusX = 1f;
                    radiusY = 0.3f;
                    if (negatiu)
                    {
                        speedRotation = 80f;
                    }
                    if (!negatiu)
                    {
                        speedRotation = -80f;
                    }
                    MovimentCuca();
                    centre.y += .005f;
                }

                if (temps > 11f && temps <= 30f)
                {
                    // Debug.Log("Cuca mou");
                    if (radiusY <= 1.5f)
                    {
                        radiusY += .005f;
                    }
                    if (radiusX <= 2f)
                    {
                        radiusX += .005f;
                    }
                    if (speedRotation >= 50 && negatiu)
                    {
                        speedRotation--;
                    }
                    if (speedRotation <= -50 && !negatiu)
                    {
                        speedRotation++;
                    }
                    MovimentCuca();
                }

                if (temps > 30f)
                {
                    // Debug.Log("Cuca baixa");
                    posicioInici = posicioCuca;
                    Journey();
                }

                if (posicioCuca == posicioAncla)
                {
                    //  Debug.Log("Stop");
                    //Debug.Log(posicioCuca);
                    //Debug.Log(posicioAncla);

                    rellotgeActiu = false;
                    plantesB      = true;

                    centre = posicioAncla;
                    if (negatiu)
                    {
                        negatiu = false;
                    }
                    if (!negatiu)
                    {
                        negatiu = true;
                    }

                    activar = true;
                }
            }

            if (!rellotgeActiu)
            {
                temps = 0f;
            }
        }



        if (tocs >= 3)
        {
            volar      = false;
            pujar      = true;
            isSpinning = true;
        }



        if (pujar)
        {
            posicioInici = posicioCuca;
            Journey2();
        }
    }