public 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 (rotacio) { if (flag3) { puntObject.transform.Rotate(xAngle, yAngle, zAngle + 2); tempo = 0; if (soDos) { soConst.clip = soPrimer; soConst.Play(); soDos = false; } } } flag2 = true; flag = true; if (gestureListener.IsRaiseLeftHand()) { Debug.Log("Click"); linia.enabled = true; // linia.speed = 0.5f; flag3 = false; if (flag) { linia.SetFloat("revert", 0.5f); } if (soUn) { soConst.clip = soSegon; soConst.Play(); soUn = false; } } if (gestureListener.IsRaiseRightHand()) { Debug.Log("Click"); linia.enabled = true; // linia.speed = 0.5f; flag3 = false; if (flag) { linia.SetFloat("revert", 0.5f); } if (soUn) { soConst.clip = soSegon; soConst.Play(); soUn = false; } } if (gestureListener.IsSwipeUp()) { Debug.Log("Click"); linia.enabled = true; // linia.speed = 0.5f; flag3 = false; if (flag) { linia.SetFloat("revert", 0.5f); } if (soUn) { soConst.clip = soSegon; soConst.Play(); soUn = false; } } if (gestureListener.IsPsi()) { Debug.Log("Click"); linia.enabled = true; // linia.speed = 0.5f; flag3 = false; if (flag) { linia.SetFloat("revert", 0.5f); } if (soUn) { soConst.clip = soSegon; soConst.Play(); soUn = false; } } } else { flag2 = false; if (tempo > 0) { linia.SetFloat("revert", -0.5f); flag = false; } //linia.speed = 0f; soUn = true; flag3 = true; soDos = true; } } } } if (flag2) { if (tempo >= 0) { tempo++; } } if (!flag) { if (tempo >= 0) { tempo--; } if (tempo <= 0) { linia.SetFloat("revert", 0f); } } if (!rotacio) { linia.SetFloat("revert", 0.5f); flag = false; } }
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(); } }