コード例 #1
0
        /// <summary>
        /// In order to move an item we catch the mouse down event to decide which
        /// thing has been selected. This function chooses either the selected
        /// cut, trigger or player.
        /// </summary>
        /// <param name="mouseLocation">Screen coordinates.</param>
        /// <param name="frame">Frame currently being designed.</param>
        /// <param name="converter">Used to convert from screen to pitch 
        /// coordinates.</param>
        public override void handleMouseDown(Point mouseLocation, 
                                         PlayFrame frame,
                                         PitchScreenCoordConverter converter,
                                         VisualOverlay overlay)
        {
            PointF pitchCoords = converter.screenToPitchCoords(mouseLocation);

              // Choose closest selected item.
              mSelectedPlayer = frame.GetClosestPlayer(pitchCoords,
                                               SELECTION_MAX_DISTANCE);
              mSelectedCut = frame.GetClosestCutEnd(pitchCoords,
                                              SELECTION_MAX_DISTANCE);
              mSelectedTrigger = frame.GetClosestTrigger(pitchCoords,
                                                 SELECTION_MAX_DISTANCE);
              mIsMovingDiscControlPoint = frame.IsNearControlPoint(pitchCoords,
                                                           SELECTION_MAX_DISTANCE);

              // Note that the ordering of priorities here MUST be the same as the
              // ordering on mouse up.
              if (mSelectedTrigger != null)
              {
            overlay.SelectedTrigger = mSelectedTrigger;
            overlay.TriggerPlayer = mSelectedTrigger.AffectedPlayer;
              }
              else if (mSelectedCut != null)
              {
            overlay.DrawingNewCut = false;
            overlay.CutStart = mSelectedCut;
              }
              else if (mSelectedPlayer != null)
              {
            overlay.SelectedPlayer = mSelectedPlayer;
              }
              else if (mIsMovingDiscControlPoint)
              {
            overlay.MovingDiscControlPoint = true;
              }
        }
コード例 #2
0
        /// <summary>
        /// Removes all of the cuts from a given starting location and a given 
        /// player. Also removes and triggers or disc movement to those cuts.
        /// </summary>
        /// <param name="clickedPlayer"></param>
        /// <param name="clickedCut">This cut will be removed as well.</param>
        internal void ClearCuts(Player clickedPlayer, 
                            LinearMovement clickedCut = null)
        {
            int totalCuts;
              int index;

              if (clickedCut == null)
              {
            // -1 because the first in the list is the starting location.
            index = 1;
              }
              else
              {
            index = PlayerMovement[clickedPlayer].IndexOf(clickedCut);
              }

              totalCuts = PlayerMovement[clickedPlayer].Count - index;

              // First we remove anything attached to the cuts that we're about to
              // delete and then we delete the cuts themselves.
              PlayerMovement[clickedPlayer].GetRange(index, totalCuts).ForEach(ClearSingleCut);
              PlayerMovement[clickedPlayer].RemoveRange(index, totalCuts);
        }
コード例 #3
0
 /// <summary>
 /// Takes a cut and replaces the element in the player movement 
 /// dictionary with the final position that the cut gets to.
 /// </summary>
 /// <param name="cut"></param>
 /// <param name="pitchCoords">New location in pitch coordinates</param>
 public void ReplaceCut(LinearMovement cut, PointF pitchCoords)
 {
     foreach (List<LinearMovement> playerCuts in PlayerMovement.Values)
       {
     if (playerCuts.Contains(cut))
     {
       playerCuts[playerCuts.IndexOf(cut)].FinalPosition = pitchCoords;
     }
       }
 }
コード例 #4
0
        /// <summary>
        /// Thsi function is used to clear a single cut of all attached elements.
        /// </summary>
        /// <param name="cut"></param>
        private void ClearSingleCut(LinearMovement cut)
        {
            Triggers.RemoveAll(trigger => trigger.CausingCutRatio.CausingCut == cut);

              if (DiscFrameMovement.ReceivingCut == cut)
              {
            ClearDiscFlightPath();
              }
        }
コード例 #5
0
        /// <summary>
        /// We capture the mouse up event and use it to place whatever it was that
        /// was selected on the mouse down event. If nothing was selected this does
        /// nothing. 
        /// </summary>
        /// <param name="mouseLocation"></param>
        /// <param name="frame"></param>
        /// <param name="converter"></param>
        public override void handleMouseUp(Point mouseLocation,
                                       PlayFrame frame,
                                       PitchScreenCoordConverter converter,
                                       VisualOverlay overlay)
        {
            PointF pitchCoords = converter.screenToPitchCoords(mouseLocation);

              if (mSelectedTrigger != null)
              {
            // If we are moving a trigger then only move it if the position it is
            // being placed is valid.
            if (frame.MaybeCreateTrigger(pitchCoords,
                                     SELECTION_MAX_DISTANCE,
                                     mSelectedTrigger.AffectedPlayer))
            {
              frame.RemoveTrigger(mSelectedTrigger);
              ModelChanged = true;
            }
              }
              else if (mSelectedPlayer != null)
              {
            frame.PlayerMovement[mSelectedPlayer][0].FinalPosition = pitchCoords;
            ModelChanged = true;
              }
              else if (mSelectedCut != null)
              {
            mSelectedCut.FinalPosition = pitchCoords;
            ModelChanged = true;
              }
              else if (mIsMovingDiscControlPoint)
              {
            frame.DiscFrameMovement.ControlPoint = pitchCoords;
            ModelChanged = true;
              }

              // Regardless of whether anything moved the move tool is complete on
              // mouse up.
              mSelectedCut = null;
              mSelectedPlayer = null;
              mSelectedTrigger = null;
              IsComplete = true;
        }
コード例 #6
0
        /// <summary>
        /// Clear all cuts up the specified one for a given player.
        /// </summary>
        /// <param name="clickedPlayer"></param>
        /// <param name="clickedCut"></param>
        internal void ClearCuts(Player clickedPlayer, 
                            LinearMovement clickedCut = null)
        {
            viewPanel.CurrentFrame.ClearCuts(clickedPlayer, clickedCut);

              viewPanel.Refresh();
              ModelChanged();
        }