예제 #1
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);
     }
 }
예제 #2
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;
 }