示例#1
0
        /// <summary>
        /// Computes the velocity of a joint given the joint history
        /// </summary>
        /// <param name="type">The type of joint to compute the velocity of</param>
        /// <returns>A vector containing the velocity of the joint</returns>
        private Vector ComputeJointVelocity(JointType type)
        {
            SkeletonPoint oldPt = pointConverter.ConvertPoint(this.skeletalHistory.First().Skeleton.Joints[type].Position);
            SkeletonPoint newPt = pointConverter.ConvertPoint(this.skeletalHistory.Last().Skeleton.Joints[type].Position);

            return(Point.Subtract(newPt.To2DPoint(), oldPt.To2DPoint()) / this.maxTimeToLive * 100); // Want the velocity for the past 50ms
        }
示例#2
0
        private void HandlePushEvent(SkeletonPoint pt, bool isPlayerOne)
        {
            if (selectingBall)
            {
                return;
            }
            SeesawObject pushedBall  = null;
            PointCanvas  ballHolder  = null;
            var          heldBalls   = isPlayerOne ? game.PlayerOneHeldBalls : game.PlayerTwoHeldBalls;
            var          ballHolders = isPlayerOne ? _playerOneBallHolders : _playerTwoBallHolders;

            foreach (var holder in ballHolders)
            {
                Rect rect = holder.GetBoundaryRect();
                if (rect.Contains(pt.To2DPoint()))
                {
                    if (holder.Children.Count > 0)
                    {
                        pushedBall = (SeesawObject)holder.Children[0];
                        ballHolder = holder;
                    }
                }
            }
            if (pushedBall != null)
            {
                int index = heldBalls.IndexOf(pushedBall);
                HitBall(index, new Vector(0, 0), isPlayerOne);
            }
        }
示例#3
0
        /// <summary>
        /// Checks whether the joint hit a rectangle and if so, return the index of the rect it hit
        /// </summary>
        /// <param name="skelPt">The skeleton point to check</param>
        /// <returns>The index of the rectangle hit if found; otherwise -1</returns>
        private int HitTestRects(SkeletonPoint skelPt)
        {
            Point pt = skelPt.To2DPoint();

            for (int i = 0; i < HitRectangles.Count; i++)
            {
                if (HitRectangles[i].Contains(pt))
                {
                    return(i);
                }
            }
            return(-1);
        }