Esempio n. 1
0
        public void TestLaserVisiblity()
        {
            Beatmap     beatmap = new Beatmap();
            TimingPoint tp;

            beatmap.TimingPoints.Add(tp = new TimingPoint
            {
                BPM = 240.0f,
            });

            var measure0 = tp.AddMeasure();
            var measure1 = tp.AddMeasure();
            var measure2 = tp.AddMeasure();

            var laserRoot = new LaserRoot
            {
                HorizontalPosition = 0.0f,
                Index    = 0,
                Position = new TimeDivision(0, 4)
            };

            laserRoot.Root = new ObjectReference(laserRoot, measure0);
            var laserEnd = new Laser
            {
                HorizontalPosition = 1.0f,
                Previous           = laserRoot.Root,
                Position           = new TimeDivision(0, 4)
            };

            laserEnd.Root  = laserRoot.Root;
            laserRoot.Next = new ObjectReference(laserEnd, measure2);

            measure0.Objects.Add(laserRoot);
            measure2.Objects.Add(laserEnd);

            BeatmapPlayback playback = new BeatmapPlayback();

            playback.ViewDuration = 0.5f;
            playback.Position     = 1.0f;
            playback.Beatmap      = beatmap;

            var lr = new ObjectReference(laserRoot, measure0);

            Assert.Contains(lr, measure1.CrossingObjects);

            Assert.AreEqual(1, playback.MeasuresInView.Count);
            Assert.AreEqual(measure1, playback.MeasuresInView[0]);
            Assert.IsTrue(playback.ObjectsInView.Contains(lr));
        }
Esempio n. 2
0
        public void TestObjectPositions()
        {
            TimingPoint testPoint = new TimingPoint();

            testPoint.Offset      = 0;
            testPoint.BPM         = 200.0;
            testPoint.Numerator   = 4;
            testPoint.Denominator = 4;

            var m0 = testPoint.AddMeasure();

            // 4 4th notes
            var b0 = new Button {
                Position = new TimeDivision(0, 4)
            };
            var b1 = new Button {
                Position = new TimeDivision(1, 4)
            };

            Assert.AreEqual(1.0 / 4.0, b1.Position.Relative);
            var b2 = new Button {
                Position = new TimeDivision(2, 4)
            };
            var b3 = new Button {
                Position = new TimeDivision(3, 4)
            };

            m0.Objects.Add(b2);
            m0.Objects.Add(b3);
            m0.Objects.Add(b1);
            m0.Objects.Add(b0);

            m0.Sort();
            Assert.AreEqual(0, m0.Objects.IndexOf(b0));
            Assert.AreEqual(3, m0.Objects.IndexOf(b3));

            // 8th note at 5
            var b25 = new Button {
                Position = new TimeDivision(5, 8)
            };

            m0.Objects.Add(b25);
            m0.Sort();

            Assert.Less(m0.Objects.IndexOf(b2), m0.Objects.IndexOf(b25));
            Assert.Less(m0.Objects.IndexOf(b25), m0.Objects.IndexOf(b3));

            Assert.AreEqual(60 / 200.0, b1.GetAbsolutePosition(m0));
            Assert.AreEqual(60 / 200.0 * 2, b2.GetAbsolutePosition(m0));
            Assert.AreEqual(60 / 400.0 * 5, b25.GetAbsolutePosition(m0));

            testPoint.InsertMeasure(0, new Measure());
            Assert.AreEqual(60 / 200.0 * 5, b1.GetAbsolutePosition(m0));
        }
Esempio n. 3
0
        public void TestRemoveInsert()
        {
            TimingPoint testPoint = new TimingPoint();
            var         m0        = testPoint.AddMeasure();
            var         m1        = testPoint.AddMeasure();
            var         m2        = testPoint.AddMeasure();

            Assert.AreEqual(0, m0.Index);
            Assert.AreEqual(2, m2.Index);

            // Remove
            testPoint.RemoveMeasure(m1);
            Assert.AreEqual(0, m0.Index);
            Assert.AreEqual(1, m2.Index);

            // Insert
            testPoint.InsertMeasure(1, m1);
            Assert.AreEqual(0, m0.Index);
            Assert.AreEqual(1, m1.Index);
            Assert.AreEqual(2, m2.Index);
        }