Exemplo n.º 1
0
        private Rise[] MakeRises(RisesModel riserModel)
        {
            if (riserModel == null)
            {
                return new Rise[] { }
            }
            ;

            var riseIndexes      = Enumerable.Range(0, riserModel.Count);
            var totalAllowedTime = settings.TrackLength - riserModel.EarliestTime;
            var rises            = riseIndexes.Select(s =>
            {
                var earliestStartTime = riserModel.EarliestTime + totalAllowedTime * s / riserModel.Count;
                var latestEndTime     =
                    riserModel.EarliestTime +
                    totalAllowedTime * (double)(s + 1) /
                    riserModel.Count; //the total time window the rise can occur in.
                var latestStartTime =
                    latestEndTime -
                    riserModel
                    .LengthEach;     // but we don't want rises to overlap (calculation too complicated if nothing else), so limit the latest start time
                if (latestStartTime < earliestStartTime)
                {
                    latestStartTime = earliestStartTime;
                }
                var startTime      = earliestStartTime + randomizer.GetRandom(0.5) * (latestStartTime - earliestStartTime);
                var endTime        = startTime + riseModel.LengthEach;
                var minAttenuation = Math.Pow(1 - riserModel.Amount, riserModel.Count - s);
                var maxAttenuation = Math.Pow(1 - riserModel.Amount, riserModel.Count - s - 1);
                return(new Rise(startTime, endTime, 1 - riserModel.Amount, 1));
            }).ToArray();

            return(rises);
        }
Exemplo n.º 2
0
        private IEnumerable <Break> MakeBreaks(BreaksModel breakModel)
        {
            Break b = null;

            if (breakModel != null)
            {
                do
                {
                    var minTime   = b?.EndTime + breakModel.MinTimeBetweenBreaks ?? breakModel.MinTimeSinceStartOfTrack;
                    var maxTime   = minTime + (breakModel.MaxTimeBetweenBreaks - breakModel.MinTimeBetweenBreaks);
                    var breakTime = minTime + (randomizer.GetRandom(0.5) * (maxTime - minTime));
                    var topLength = breakModel.MinLength + (randomizer.GetRandom(0.5) * (breakModel.MaxLength - breakModel.MinLength));
                    b = new Break(breakTime, topLength, breakModel.RampLength);
                    yield return(b);
                } while (b.EndTime < settings.TrackLength);
            }
        }