Choreoh.Global.checkSwipe C# (CSharp) Method

checkSwipe() private static method

private static checkSwipe ( float tolerance, LinkedList moves ) : void
tolerance float
moves LinkedList
return void
        private static void checkSwipe(float tolerance, LinkedList<Skeleton> moves)
        {
            int i = 0;
            if (!canGesture)
                return;
            LinkedList<Skeleton> temp = moves;
            Joint prevJoint = new Joint();
            Joint firstJoint = moves.First<Skeleton>().Joints[JointType.HandRight];
            Joint lastJoint = moves.Last<Skeleton>().Joints[JointType.HandRight];
            foreach (Skeleton skeleton in moves)
            {
                //find better implementation, but moves too long for checking swipes so skip first few
                if (i < 3)
                {
                    i++;
                    continue;
                }
                Joint joint = skeleton.Joints[JointType.HandRight];
                if (prevJoint.Position.Z == 0.0)//not the best but checks if empty joint
                {
                    prevJoint = joint;
                    continue;
                }
                if (prevJoint.Position.X > joint.Position.X + tolerance)
                {
                    prevJoint = joint;
                    continue;
                }
                return;
            }
            if ((Math.Abs(lastJoint.Position.X - firstJoint.Position.X) > .30) && Math.Abs(lastJoint.Position.Y - firstJoint.Position.Y) < .20)
            {
                canGesture = false;
                lastGesture = "Swiped";
                canGestureTimer.Start();
            }
        }