diff --git a/Assets/MotionNotes/Jump.cs b/Assets/MotionNotes/Jump.cs index 2e8b703f990ea20d8dca35d3d944b6b2be8bae72..0d3a952edfeed38471e6b521bd6a008f8b663c81 100644 --- a/Assets/MotionNotes/Jump.cs +++ b/Assets/MotionNotes/Jump.cs @@ -18,23 +18,41 @@ public class Jump : MotionNote } public Jump(float timing) : base(timing) { + downCount = 0; } + private float spineHeight; + private int downCount; + public override IEnumerator Checkpoint() { - var motionState = InputManager.Instance.CurrentMotionState; - var motion = motionState; + float currentSpineHeight + = InputManager.Instance + .Joints[Windows.Kinect.JointType.SpineBase].Position.Y; + + while (downCount < 10 && currentSpineHeight <= spineHeight - 0.1f) + { + spineHeight = currentSpineHeight; + currentSpineHeight + = InputManager.Instance + .Joints[Windows.Kinect.JointType.SpineBase].Position.Y; - while (motion != MotionState.CLAP_PREPARE) + downCount++; yield return false; + } - Activated = true; + if (downCount >= 10) + Activated = true; yield break; } public override bool FinalJudgeAction() { - throw new NotImplementedException(); + float currentSpineHeight + = InputManager.Instance + .Joints[Windows.Kinect.JointType.SpineBase].Position.Y; + + return currentSpineHeight >= spineHeight; } } diff --git a/Assets/Script/InputManager.cs b/Assets/Script/InputManager.cs index ec544fe4f0c28d4e0196ff8fd87a7faa3735679f..304e6ac9930bfca359d86dbac68c7c6d574a6af4 100644 --- a/Assets/Script/InputManager.cs +++ b/Assets/Script/InputManager.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using Windows.Kinect; using System.IO; using UnityEngine.UI; @@ -29,6 +30,7 @@ public class InputManager : MonoBehaviour { } public MotionState CurrentMotionState { get; set; } + public Dictionary<JointType, Windows.Kinect.Joint> Joints { get; set; } public bool IsButtonPressed { diff --git a/Assets/Script/JudgeManager.cs b/Assets/Script/JudgeManager.cs index 3f367c033379f47e3824e51b20b003c395f712ee..1e348d90940a5a2f8ca16c74ed9ab34786ba050d 100644 --- a/Assets/Script/JudgeManager.cs +++ b/Assets/Script/JudgeManager.cs @@ -73,6 +73,7 @@ public class JudgeManager : MonoBehaviour activatedNotes = new List<MotionNote>(); LoadNotes(GameManager.Instance.CurrentTrack.Notes); + Instantiate(GameManager.Instance.CurrentTrack.BGM); } // Update is called once per frame diff --git a/Assets/Script/MotionView.cs b/Assets/Script/MotionView.cs index 56526bcf0c920a8c237d8a826e61498e45617e59..b79647025ece4f787f6cea51014e12ca8a1be235 100644 --- a/Assets/Script/MotionView.cs +++ b/Assets/Script/MotionView.cs @@ -52,16 +52,22 @@ public class MotionView : MonoBehaviour { leftHand = body[idx].Joints[JointType.HandLeft ] .Position, rightHand = body[idx].Joints[JointType.HandRight] - .Position; + .Position, + spineShoulder = body[idx].Joints[JointType.SpineShoulder] + .Position; MotionState s = MotionState.UNKNOWN; if (head.Y < leftHand.Y && head.Y < rightHand.Y) s |= MotionState.HURRAY; - if (Distance(leftHand, rightHand) > 0.3f) + if (Distance(leftHand, rightHand) > 0.3f + && spineShoulder.Y < leftHand.Y && spineShoulder.Y < rightHand.Y) s |= MotionState.CLAP_PREPARE; - if (Distance(leftHand, rightHand) < 0.1f) + if (Distance(leftHand, rightHand) < 0.1f + && spineShoulder.Y < leftHand.Y && spineShoulder.Y < rightHand.Y) s |= MotionState.CLAP_DONE; + InputManager.Instance.Joints = body[idx].Joints; + return s; } diff --git a/Assets/Script/TrackInfo.cs b/Assets/Script/TrackInfo.cs index 852e8bec137591782a0649e60bf71532b922ea89..c76f0be4b12c834b9f89ba6705ff54be3da4a9ac 100644 --- a/Assets/Script/TrackInfo.cs +++ b/Assets/Script/TrackInfo.cs @@ -12,6 +12,8 @@ public class TrackInfo public float BPM { get; private set; } public int Level { get; private set; } + public AudioClip BGM { get; private set; } + public List<string> TrackList { get; private set; } public List<Note> Notes { get; private set; } @@ -68,6 +70,9 @@ public class TrackInfo case "#TRACKLIST": TrackList.Add(value); break; + case "#WAV": + BGM = new WWW("file:///" + file.DirectoryName + '\\' + value).GetAudioClip(); + break; } } }