﻿using Microsoft. Kinect;

namespace LightBuzz. Vitruvius. Gestures
{
    public class WaveRightSegment1 : IGestureSegment
    {
        /// <summary>
        /// Updates the current gesture. 
        /// </summary>
        /// <param name="skeleton">The skeleton.</param>
        /// <returns>A GesturePartResult based on whether the gesture part has been completed.</returns>
        public GesturePartResult Update(Skeleton skeleton)
        {
            // Hand above elbow
            if (skeleton. Joints[JointType. HandRight].Position. Y > skeleton. Joints[JointType. ElbowRight].Position. Y)
            {
                // Hand right of elbow
                if (skeleton. Joints[JointType. HandRight].Position. X > skeleton. Joints[JointType. ElbowRight].Position. X)
                {
                    return GesturePartResult. Succeeded;
                }

                // Hand has not dropped but is not quite where we expect it to be, pausing till next frame
                return GesturePartResult. Undetermined;
            }

            // Hand dropped - no gesture fails
            return GesturePartResult. Failed;
        }
    }

    public class WaveRightSegment2 : IGestureSegment
    {
        /// <summary>
        /// Updates the current gesture. 
        /// </summary>
        /// <param name="skeleton">The skeleton.</param>
        /// <returns>A GesturePartResult based on whether the gesture part has been completed.</returns>
        public GesturePartResult Update(Skeleton skeleton)
        {
            // Hand above elbow
            if (skeleton. Joints[JointType. HandRight].Position. Y > skeleton. Joints[JointType. ElbowRight].Position. Y)
            {
                // Hand left of elbow
                if (skeleton. Joints[JointType. HandRight].Position. X < skeleton. Joints[JointType. ElbowRight].Position. X)
                {
                    return GesturePartResult. Succeeded;
                }

                // Hand has not dropped but is not quite where we expect it to be, pausing till next frame
                return GesturePartResult. Undetermined;
            }

            // Hand dropped - no gesture fails
            return GesturePartResult. Failed;
        }
    }
}
