コード例 #1
0
        private void AddPitStopToStrategy(int driverIndex, int lapNumber)
        {
            Strategy thisStrategy = strategyViewerData.GetStrategy(driverIndex);
            bool     stopWithinRange;
            int      nearestStop = thisStrategy.GetNearestPitStop(lapNumber, 1, out stopWithinRange);

            if (stopWithinRange)
            {
                thisStrategy.Stints = thisStrategy.RemovePitStop(nearestStop);
            }
            else
            {
                thisStrategy.Stints = thisStrategy.AddPitStop(lapNumber);
            }

            thisStrategy.UpdateStrategyParameters();
            MyEvents.OnStrategyModified(Data.Drivers[driverIndex], thisStrategy, false);
        }
コード例 #2
0
        /// <summary>
        /// Handles the button clicked events on any of the buttons within the control.
        /// </summary>
        /// <param name="controlNumber">The control number that fired the event</param>
        void ButtonClicked(int controlNumber)
        {
            int startLapNumber = thisStrategy.Stints[stintIndex].startLap;
            int midLapNumber   = (int)((thisStrategy.Stints[stintIndex].stintLength) / 2) + startLapNumber;

            //Performs the required action on the strategy:
            switch (controlNumber)
            {
            case 0: thisStrategy.SwapStints(stintIndex - 1, stintIndex); break;              //moves stint up

            case 1: thisStrategy.SwapStints(stintIndex, stintIndex + 1); break;              //moves stint down

            case 2: thisStrategy.Stints = thisStrategy.AddPitStop(midLapNumber); break;      //splits stint

            case 3: thisStrategy.Stints = thisStrategy.RemovePitStop(startLapNumber); break; //merges stint with previous
            }

            //Updates the strategy's parameters
            thisStrategy.UpdateStrategyParameters();
            MyEvents.OnStrategyModified(thisDriver, thisStrategy, false);
        }