コード例 #1
0
 private void Trigger(InteractionDirection interactionDirection, InstructionCaller instruction, MovementDirection direction)
 {
     if (Direction.Contains(interactionDirection, direction))
     {
         Trigger(instruction);
     }
 }
コード例 #2
0
        public static bool Contains(InteractionDirection interactionDirection, MovementDirection movementDirection)
        {
            // If the movement direction that is sent in is None it means that the interaction is on the current tile, not the one the player is facing
            var direction = ToInteractionDirection(movementDirection);

            return((interactionDirection == InteractionDirection.Any && direction != InteractionDirection.This) ||
                   (interactionDirection == InteractionDirection.This && direction == InteractionDirection.This) ||
                   (((int)direction & (int)interactionDirection) > 0));
        }
コード例 #3
0
        private bool checkAngle(KinectDataPoint p1, KinectDataPoint p2, InteractionDirection direction, int bodyAngle)
        {
            int horizontalAngle = p1.CalcHorizontalAngle(p2);
            int depthAngle = p1.CalcDepthAngle(p2);

            bool result = checkUpDown(p1, p2, depthAngle, horizontalAngle, direction) ||
                checkLeftRight(p1, p2, depthAngle, horizontalAngle, bodyAngle, direction);

            return result;
        }
コード例 #4
0
        private bool checkLeftRight(KinectDataPoint p1, KinectDataPoint p2, int depthAngle,
            int horizontalAngle, int bodyAngle, InteractionDirection direction)
        {
            if (direction == InteractionDirection.TO_LEFT || direction == InteractionDirection.TO_RIGHT)
            {
                if (Math.Abs(bodyAngle - depthAngle) < IConsts.GSwipeDepthAngle)
                {
                    bool directionOk;

                    if (direction == InteractionDirection.TO_LEFT)
                    {
                        directionOk = (p1.ScreenX > p2.ScreenX);
                    }
                    else
                    {
                        directionOk = (p1.ScreenX < p2.ScreenX);
                    }
                    return (horizontalAngle < IConsts.GSwipeHorizontalAngle) && directionOk;
                }
            }
            return false;
        }
コード例 #5
0
 private bool checkSwipeGesture(int bodyAngle, List<KinectDataPoint> queue, InteractionDirection direction)
 {
     for (int i = 0; i < queue.Count; ++i)
     {
         if (checkSwipeGesture(bodyAngle, queue, i, direction))
         {
             return true;
         }
     }
     return false;
 }
コード例 #6
0
        private bool checkUpDown(KinectDataPoint p1, KinectDataPoint p2, int depthAngle,
            int horizontalAngle, InteractionDirection direction)
        {
            if (direction == InteractionDirection.UP || direction == InteractionDirection.DOWN)
            {
                if (depthAngle < IConsts.GSwipeDepthAngle)
                {
                    bool directionOk;

                    if (direction == InteractionDirection.UP)
                    {
                        directionOk = (p1.ScreenY > p2.ScreenY);
                    }
                    else
                    {
                        directionOk = (p1.ScreenY < p2.ScreenY);
                    }
                    return ((90 - horizontalAngle) < IConsts.GSwipeHorizontalAngle) && directionOk;
                }
            }
            return false;
        }
コード例 #7
0
        private bool checkSwipeGesture(int bodyAngle, List<KinectDataPoint> queue, int stepSize, InteractionDirection direction)
        {
            int minPoints = stepSize + 1;

            for (int i = 0; i < queue.Count - minPoints; ++i)
            {
                KinectDataPoint p1 = queue.ElementAt(i);
                KinectDataPoint p2 = queue.ElementAt(i + stepSize);

                if (p1.TimeStamp.AddMilliseconds(maxSwipeTime) < p2.TimeStamp)
                {
                    break;
                }

                double length = p1.CalcDistance3D(p2);

                if (length >= IConsts.GSwipeMinLength)
                {
                    if (checkAngle(p1, p2, direction, bodyAngle))
                    {
                        KinectDataPoint pMiddle = queue.ElementAt(i + (stepSize / 2));

                        if (checkAngle(p1, pMiddle, direction, bodyAngle))
                        {
                            return true;
                        }
                    }
                }
            }
            return false;
        }