public void TestSingleNoteWithLongTime()
        {
            // |     |
            // | *** |
            // |     |

            var beatmap = new KaraokeBeatmap();

            beatmap.HitObjects.Add(new Note
            {
                Display   = true,
                StartTime = 1000,
                Duration  = 1000,
                Text      = "karaoke!",
                Tone      = new Tone(0, true)
            });

            var generated = new KaraokeAutoGenerator(beatmap).Generate();

            Assert.IsTrue(generated.Frames.Count == 11, "Replay must have 11 frames,Start, duration(9 frames) and end.");
            Assert.AreEqual(1000, generated.Frames[0].Time, "Incorrect hit time");
            Assert.AreEqual(2001, generated.Frames[10].Time, "Incorrect time");
            Assert.IsTrue(checkMatching(generated.Frames[0], new Tone(0, true)), "Fist frame should sing.");
            Assert.IsTrue(checkMatching(generated.Frames[10], null), "Last frame should not sing.");
        }
        public void TestNoteStair()
        {
            // |      |
            // |    - |
            // | -    |

            var beatmap = new KaraokeBeatmap();

            beatmap.HitObjects.Add(new Note
            {
                Display   = true,
                StartTime = 1000,
                Duration  = 50,
                Text      = "kara",
                Tone      = new Tone(0, true)
            });
            beatmap.HitObjects.Add(new Note
            {
                Display   = true,
                StartTime = 1050,
                Duration  = 50,
                Text      = "oke!",
                Tone      = new Tone(1, true)
            });

            var generated = new KaraokeAutoGenerator(beatmap).Generate();

            Assert.IsTrue(generated.Frames.Count == 3, "Replay must have 3 frames, note1's start, note2's start and note2's end.");
            Assert.AreEqual(1000, generated.Frames[0].Time, "Incorrect time");
            Assert.AreEqual(1050, generated.Frames[1].Time, "Incorrect time");
            Assert.AreEqual(1101, generated.Frames[2].Time, "Incorrect time");
            Assert.IsTrue(checkMatching(generated.Frames[0], new Tone(0, true)), "Frame1 should sing.");
            Assert.IsTrue(checkMatching(generated.Frames[1], new Tone(1, true)), "Frame2 should sing.");
            Assert.IsTrue(checkMatching(generated.Frames[2], null), "Frame3 should release sing.");
        }
Exemple #3
0
        public virtual void ApplyToDrawableRuleset(DrawableRuleset <KaraokeHitObject> drawableRuleset)
        {
            // Got no idea why edit ruleset call this shit.
            if (drawableRuleset is DrawableKaraokeEditorRuleset)
            {
                return;
            }

            if (!(drawableRuleset.Playfield is KaraokePlayfield karaokePlayfield))
            {
                return;
            }

            // todo : add replay visualization into note playfield from here?
            // todo : should have a better way(or called more generic) way to apply replay into replay field.
            var replay        = new KaraokeAutoGenerator(drawableRuleset.Beatmap).Generate();
            var notePlayfield = karaokePlayfield.NotePlayfield as NotePlayfield;
            var frames        = replay.Frames.OfType <KaraokeReplayFrame>();

            // for safety purpose should clear reply to make sure not cause crash if apply to ruleset runs more then one times.
            notePlayfield?.ClearReplay();

            foreach (var frame in frames)
            {
                notePlayfield?.AddReplay(frame);
            }
        }