Пример #1
0
        private void loadBarLines()
        {
            var taikoPlayfield = Playfield as TaikoPlayfield;

            if (taikoPlayfield == null)
            {
                return;
            }

            TaikoHitObject lastObject  = Beatmap.HitObjects[Beatmap.HitObjects.Count - 1];
            double         lastHitTime = 1 + (lastObject as IHasEndTime)?.EndTime ?? lastObject.StartTime;

            var timingPoints = Beatmap.ControlPointInfo.TimingPoints.ToList();

            if (timingPoints.Count == 0)
            {
                return;
            }

            int    currentIndex = 0;
            int    currentBeat  = 0;
            double time         = timingPoints[currentIndex].Time;

            while (time <= lastHitTime)
            {
                int nextIndex = currentIndex + 1;
                if (nextIndex < timingPoints.Count && time > timingPoints[nextIndex].Time)
                {
                    currentIndex = nextIndex;
                    time         = timingPoints[currentIndex].Time;
                    currentBeat  = 0;
                }

                var currentPoint = timingPoints[currentIndex];

                var barLine = new BarLine
                {
                    StartTime = time,
                };

                barLine.ApplyDefaults(Beatmap.ControlPointInfo, Beatmap.BeatmapInfo.Difficulty);

                bool isMajor = currentBeat % (int)currentPoint.TimeSignature == 0;
                taikoPlayfield.AddBarLine(isMajor ? new DrawableBarLineMajor(barLine) : new DrawableBarLine(barLine));

                double bl = currentPoint.BeatLength;
                if (bl < 800)
                {
                    bl *= (int)currentPoint.TimeSignature;
                }

                time += bl;
                currentBeat++;
            }
        }
Пример #2
0
        private void createBar(bool isMajor, double increaseTime = 2000)
        {
            notePlayfields.ForEach(x =>
            {
                var bar = new BarLine {
                    StartTime = Time.Current + increaseTime, Major = isMajor
                };
                bar.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());

                x.Add(bar);
            });
        }
Пример #3
0
        private void createBarLine(bool major)
        {
            foreach (var stage in stages)
            {
                var obj = new BarLine
                {
                    StartTime = Time.Current + 2000,
                    Major     = major,
                };

                obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());

                stage.Add(obj);
            }
        }
Пример #4
0
        private BarLine createBarLineAtCurrentTime(bool major = false)
        {
            var barLine = new BarLine
            {
                Major     = major,
                StartTime = Time.Current + 2000,
            };

            var cpi = new ControlPointInfo();

            cpi.Add(0, new TimingControlPoint {
                BeatLength = 500
            });

            barLine.ApplyDefaults(cpi, new BeatmapDifficulty());

            return(barLine);
        }
Пример #5
0
        private void loadBarLines()
        {
            var taikoPlayfield = Playfield as TaikoPlayfield;

            if (taikoPlayfield == null)
            {
                return;
            }

            TaikoHitObject lastObject  = Beatmap.HitObjects[Beatmap.HitObjects.Count - 1];
            double         lastHitTime = 1 + (lastObject as IHasEndTime)?.EndTime ?? lastObject.StartTime;

            var timingPoints = Beatmap.TimingInfo.ControlPoints.FindAll(cp => cp.TimingChange);

            if (timingPoints.Count == 0)
            {
                return;
            }

            int currentIndex = 0;

            while (currentIndex < timingPoints.Count && Precision.AlmostEquals(timingPoints[currentIndex].BeatLength, 0))
            {
                currentIndex++;
            }

            double time          = timingPoints[currentIndex].Time;
            double measureLength = timingPoints[currentIndex].BeatLength * (int)timingPoints[currentIndex].TimeSignature;

            // Find the bar line time closest to 0
            time -= measureLength * (int)(time / measureLength);

            // Always start barlines from a positive time
            while (time < 0)
            {
                time += measureLength;
            }

            int currentBeat = 0;

            while (time <= lastHitTime)
            {
                ControlPoint current = timingPoints[currentIndex];

                if (time > current.Time || current.OmitFirstBarLine)
                {
                    bool isMajor = currentBeat % (int)current.TimeSignature == 0;

                    var barLine = new BarLine
                    {
                        StartTime = time,
                    };

                    barLine.ApplyDefaults(Beatmap.TimingInfo, Beatmap.BeatmapInfo.Difficulty);

                    taikoPlayfield.AddBarLine(isMajor ? new DrawableBarLineMajor(barLine) : new DrawableBarLine(barLine));

                    currentBeat++;
                }

                double bl = current.BeatLength;

                if (bl < 800)
                {
                    bl *= (int)current.TimeSignature;
                }

                time += bl;

                if (currentIndex + 1 >= timingPoints.Count || time < timingPoints[currentIndex + 1].Time)
                {
                    continue;
                }

                currentBeat = 0;
                currentIndex++;
                time = timingPoints[currentIndex].Time;
            }
        }