/// <summary> /// Update /// Standard Unity Method, if it can, it researches a gesture. /// </summary> // Update is called once per frame void Update() { if (recognizer != null) { KinectOverlay.Gesture recognizedGesture = recognizer.TryToGetGesture(); if (recognizedGesture.GestureName != null) { OnGestureRecognition(recognizedGesture); } } }
/// <summary> /// OnGestureRecognition /// Given a gesture, this function will identify it and, if no other gesture is being process, /// will process to call the recognition procedure. /// </summary> /// <param name="recognizedGesture"></param> public void OnGestureRecognition(KinectOverlay.Gesture recognizedGesture) { if (!processingGesture) { GesturesForDemo gestureName = GesturesForDemo.NONE; switch (recognizedGesture.GestureName) { case "SwipeRight": gestureName = GesturesForDemo.RightSwipe; break; case "SwipeLeft": gestureName = GesturesForDemo.LeftSwipe; break; case "SwipeUp": gestureName = GesturesForDemo.SwipeUp; break; case "SwipeUp2": gestureName = GesturesForDemo.SwipeUp; break; case "Punch": gestureName = GesturesForDemo.Punch; break; case "Run": gestureName = GesturesForDemo.Run; break; case "PraiseTheSun": gestureName = GesturesForDemo.PraiseTheSun; break; default: break; } if (currentTrial < gesturesToCheck.Count * trialsPerGesture) { StartCoroutine(ProcessGesture(gestureName)); } else { // In case we're at the end of the level and we use the gesture to get back to the mainMenu. if (gestureName == GesturesForDemo.PraiseTheSun && levelChanger != null) { levelChanger.LoadMainMenu(); } } } }
/// <summary> /// OnGestureRecognition /// Given a gesture, this function will identify it and, if no other gesture is being process, /// will process to call the recognition procedure. /// </summary> /// <param name="recognizedGesture"></param> public void OnGestureRecognition(KinectOverlay.Gesture recognizedGesture) { if (!processingGesture) { GesturesForDemo gestureName = GesturesForDemo.NONE; switch (recognizedGesture.GestureName) { case "SwipeRight": gestureName = GesturesForDemo.RightSwipe; break; case "SwipeLeft": gestureName = GesturesForDemo.LeftSwipe; break; case "SwipeUp": gestureName = GesturesForDemo.SwipeUp; break; case "Punch": gestureName = GesturesForDemo.Punch; break; case "Run": gestureName = GesturesForDemo.Run; break; case "PraiseTheSun": gestureName = GesturesForDemo.PraiseTheSun; break; default: break; } // In case the user made the praise the sun gesture two times, it gets back to the menue. if (levelChanger != null && lastRecognizedGesture == GesturesForDemo.PraiseTheSun && gestureName == GesturesForDemo.PraiseTheSun) { levelChanger.LoadMainMenu(); } else { StartCoroutine(ProcessGesture(gestureName)); } } }