Example #1
0
        private static RuntimeNote[] CreateNotes(SourceNote note, Conductor[] conductors, SourceNote[] gameNotes, ref int currentID)
        {
            RuntimeNote[] notesToBeAdded;

            switch (note.Type)
            {
            case NoteType.Tap:
                notesToBeAdded = MyCreateTapNote(note, conductors, ref currentID);
                break;

            case NoteType.Flick:
            case NoteType.Hold:
            case NoteType.Slide:
                notesToBeAdded = ScoreCompileHelper.CreateContinuousNotes(note, conductors, ref currentID);
                break;

            case NoteType.Special:
                notesToBeAdded = ScoreCompileHelper.CreateSpecialNotes(note, conductors, gameNotes, ref currentID);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(notesToBeAdded);
        }
Example #2
0
        private static RuntimeNote[] MyCreateTapNote(SourceNote note, Conductor[] conductors, ref int currentID)
        {
            var rns = ScoreCompileHelper.CreateTapNote(note, conductors, ref currentID);

            if (note.ExtraInfo != null && note.ExtraInfo.ContainsKey("abc"))
            {
                var dyn = note.ExtraInfo.Clone();
                dyn.SetValue("def", 123);
                rns[0].ExtraInfo = dyn;
            }
            return(rns);
        }
        private static void WriteConductor([NotNull] this TextWriter writer, [NotNull] SourceScore sourceScore, int index)
        {
            writer.WriteLine($"		[{index}]");

            var conductor = sourceScore.Conductors[index];

            writer.WriteLine("		EventConductorData data");

            var absTime = ScoreCompileHelper.TicksToSeconds(conductor.Ticks, sourceScore.Conductors);

            writer.WriteLine("			double absTime = "+ absTime.ToString(CultureInfo.InvariantCulture));
            writer.WriteLine("			UInt8 selected = 0");
            writer.WriteLine("			SInt64 tick = "+ conductor.Ticks.ToString());
            writer.WriteLine("			int measure = "+ conductor.Measure.ToString());
            writer.WriteLine("			int beat = "+ conductor.Beat.ToString());
            writer.WriteLine("			int track = 0");
            writer.WriteLine("			double tempo = "+ conductor.Tempo.ToString(CultureInfo.InvariantCulture));
            writer.WriteLine("			int tsigNumerator = "+ conductor.SignatureNumerator.ToString());
            writer.WriteLine("			int tsigDenominator = "+ conductor.SignatureDenominator.ToString());
            writer.WriteLine("			string marker = \"\"");
        }
        private static void WriteEventNote([NotNull] this TextWriter writer, [NotNull] SourceScore sourceScore, [NotNull, ItemNotNull] SourceNote[] notes, int index, TrackType trackType)
        {
            writer.WriteLine($"		[{index}]");

            var sourceNote = notes[index];

            writer.WriteLine("		EventNoteData data");

            // MLTD: "offset > 0" means music is AFTER the beatmap
            // MilliSim: "offset > 0" means music is BEFORE the beatmap
            var absTime = ScoreCompileHelper.TicksToSeconds(sourceNote.Ticks, sourceScore.Conductors);

            writer.WriteLine("			double absTime = "+ absTime.ToString(CultureInfo.InvariantCulture));
            writer.WriteLine("			UInt8 selected = 0");
            writer.WriteLine("			SInt64 tick = "+ (sourceNote.Ticks / (NoteBase.TicksPerBeat / 8)).ToString());

            if (sourceNote.Type < 0)
            {
                writer.WriteLine("			int measure = "+ sourceNote.Measure.ToString());
                writer.WriteLine("			int beat = "+ sourceNote.Beat.ToString());

                writer.WriteLine("			int track = -1");
            }
            else
            {
                writer.WriteLine("			int measure = 0");
                writer.WriteLine("			int beat = 0");

                var tracks = MltdHelper.GetTrackIndicesFromTrackType(trackType);

                writer.WriteLine("			int track = "+ tracks[sourceNote.TrackIndex].ToString());
            }

            writer.WriteLine("			int type = "+ ((int)MltdHelper.GetMltdNoteType(sourceNote)).ToString());
            writer.WriteLine("			float startPosx = "+ sourceNote.StartX.ToString(CultureInfo.InvariantCulture));
            writer.WriteLine("			float endPosx = "+ sourceNote.EndX.ToString(CultureInfo.InvariantCulture));
            writer.WriteLine("			float speed = "+ sourceNote.Speed.ToString(CultureInfo.InvariantCulture));

            if (sourceNote.FollowingNotes != null && sourceNote.FollowingNotes.Length > 0)
            {
                var duration = (int)((sourceNote.FollowingNotes[sourceNote.FollowingNotes.Length - 1].Ticks - sourceNote.Ticks) / (NoteBase.TicksPerBeat / 8));
                writer.WriteLine("			int duration = "+ duration.ToString());
            }
            else
            {
                writer.WriteLine("			int duration = 0");
            }

            writer.WritePolyPoints(sourceNote, sourceNote.FollowingNotes);

            if (sourceNote.FollowingNotes != null && sourceNote.FollowingNotes.Length > 0)
            {
                writer.WriteLine("			int endType = "+ ((int)sourceNote.FollowingNotes[sourceNote.FollowingNotes.Length - 1].FlickDirection).ToString());
            }
            else
            {
                writer.WriteLine("			int endType = 0");
            }

            if (sourceNote.Type < 0)
            {
                writer.WriteLine("			double leadTime = 0");
            }
            else
            {
                // TODO: What is this "magic number"?
                const double someConstant = 198.3471011848414;
                var          bpm          = ScorePreprocessor.GetCurrentBpm(sourceNote.Ticks, sourceScore.Conductors);
                var          leadTime     = someConstant / bpm;
                // TODO: Another guess... Didn't look too carefully inside speed variated notes.
                leadTime /= sourceNote.Speed;
                writer.WriteLine("			double leadTime = "+ leadTime.ToString(CultureInfo.InvariantCulture));
            }
        }
Example #5
0
 public RuntimeScore Compile(SourceScore score, ScoreCompileOptions compileOptions)
 {
     compileOptions.Offset = (float)score.MusicOffset;
     return(ScoreCompileHelper.CompileScore(score, compileOptions));
 }
Example #6
0
        /**
         * A demonstration of the usage of ScoreCompilerHelper methods.
         */

        private RuntimeScore MyCompile(SourceScore score, ScoreCompileOptions compileOptions)
        {
            return(ScoreCompileHelper.CompileScore(score, compileOptions, CreateNotes));
        }
Example #7
0
 /// <summary>
 /// Compiles a <see cref="SourceScore"/> to a <see cref="RuntimeScore"/>, which will be used by the player.
 /// A <see cref="ScoreCompileOptions"/> object can be specified.
 /// </summary>
 /// <param name="score">The <see cref="SourceScore"/> to compile.</param>
 /// <param name="compileOptions">Compile options.</param>
 /// <returns>Compiled score.</returns>
 public RuntimeScore Compile(SourceScore score, ScoreCompileOptions compileOptions)
 {
     return(ScoreCompileHelper.CompileScore(score, compileOptions));
 }
        private static void WriteNotes([NotNull] this TextWriter writer, [NotNull] SourceScore score, [NotNull] ScenarioScrObj template)
        {
            var notes    = score.Notes;
            var noteList = new List <EventScenarioData>();

            var specialNote = notes.FirstOrDefault(n => n.Type == NoteType.Special);

            // Mofify time: the tap buttons animation before the special note (the big round note)
            if (specialNote != null)
            {
                noteList.AddRange(template.scenario);

                var animNote = noteList.Find(n => n.type == ScenarioNoteType.BeginTapButtonsAnimation);

                if (animNote != null)
                {
                    var specialNoteTime = ScoreCompileHelper.TicksToSeconds(specialNote.Ticks, score.Conductors);

                    animNote.absTime = specialNoteTime - 0.5f;
                    animNote.tick    = ScorePreprocessor.SecondsToTicks(animNote.absTime, score.Conductors);
                }

                // Modify time: second tap buttons appearing time (the one that is after the special note)
                var reappearNote = notes.FirstOrDefault(n => n.Ticks > specialNote.Ticks);

                if (reappearNote != null && animNote != null)
                {
                    var reaNote = noteList.Where(n => n.type == ScenarioNoteType.ShowTapButtons).Skip(1).FirstOrDefault();

                    if (reaNote != null)
                    {
                        var reappearNoteTime = ScoreCompileHelper.TicksToSeconds(reappearNote.Ticks, score.Conductors);

                        reaNote.absTime = reappearNoteTime - 0.8f;
                        reaNote.tick    = ScorePreprocessor.SecondsToTicks(reaNote.absTime, score.Conductors);
                    }
                }
            }

            noteList.Sort((n1, n2) => {
                var t = n1.tick.CompareTo(n2.tick);

                if (t != 0)
                {
                    return(t);
                }

                t = ((int)n1.type).CompareTo((int)n2.type);

                if (t != 0)
                {
                    return(t);
                }

                t = n1.idol.CompareTo(n2.idol);

                if (t != 0)
                {
                    return(t);
                }

                return(n1.track.CompareTo(n2.track));
            });

            writer.Write(@"EventScenarioData scenario
	Array Array
	int size = "    );
            writer.WriteLine(noteList.Count.ToString());

            for (var i = 0; i < noteList.Count; ++i)
            {
                var sn = noteList[i];

                writer.WriteLine("		[{0}]", i.ToString());
                writer.WriteScenarioNote(2, "data", sn);
            }
        }