コード例 #1
0
        private IEnumerable <ShowLight> GenerateFogNotes(ArrangementData arrangement)
        {
            var fogFunctions = new FogGenerationFunctions(arrangement.MidiNotes, fogOptions.RandomizeColors);

            switch (fogOptions.GenerationMethod)
            {
            case SingleColor:
                return(Enumerable.Repeat(new ShowLight(arrangement.FirstBeatTime, fogOptions.SelectedSingleFogColor), 1));

            case ChangeEveryNthBar:
                return(fogFunctions.FromBarNumbers(arrangement.Ebeats, fogOptions.ChangeFogColorEveryNthBar));

            case MinTimeBetweenChanges:
                return(fogFunctions.FromMinTime(fogOptions.MinTimeBetweenNotes));

            case FromSectionNames:
                return(fogFunctions.FromSections(arrangement.Sections));

            case FromLowestOctaveNotes:
                int min = arrangement.LowOctaveMinMidiNote;
                int max = arrangement.LowOctaveMaxMidiNote;

                return(fogFunctions.ConditionalGenerate(mn => mn.Note >= min && mn.Note <= max));

            case FromChords:
                return(fogFunctions.ConditionalGenerate(mn => mn.WasChord));

            default:
                Debug.Print("ERROR: Unknown fog generation method.");
                return(Enumerable.Empty <ShowLight>());
            }
        }
コード例 #2
0
        // Ensures that at least one note of the type is present and moves the first note to the start of the beatmap.
        private void ValidateFirstNoteOfType(List <ShowLight> showlights, ShowLightType showlightType)
        {
            int firstNoteIndex = showlights.FindIndex(sl => sl.GetShowLightType() == showlightType);

            if (firstNoteIndex == -1)
            {
                // Add new random note if not found
                showlights.Insert(0,
                                  new ShowLight(FirstBeatTime,
                                                showlightType == ShowLightType.Fog ? FogGenerationFunctions.GetRandomFogNote() : BeamGenerationFunctions.GetRandomBeamNote())
                                  );
            }
            else if (showlights[firstNoteIndex].Time != FirstBeatTime)
            {
                // Move first note to start of the beatmap
                showlights[firstNoteIndex] = new ShowLight(FirstBeatTime, showlights[firstNoteIndex].Note);
            }
        }
コード例 #3
0
        public IEnumerable <ShowLight> FromMinTime(
            List <ShowLight> currentShowlights,
            List <Section> sections,
            float minTime,
            bool useCompatible)
        {
            int minTimeMs    = (int)(minTime * 1000f);
            int previousNote = -1;
            int previousTime = 0;

            foreach (var midiNote in MidiNotes)
            {
                if (midiNote.Time - previousTime < minTimeMs || midiNote.Time == previousTime)
                {
                    continue;
                }

                byte beamNote;

                if (useCompatible)
                {
                    var activeFog =
                        currentShowlights
                        .LastOrDefault(sl => sl.Time <= midiNote.Time && sl.IsFog());

                    byte[] compColorTable = (activeFog is null) ?
                                            CompatibleColors[FogGenerationFunctions.GetRandomFogNote()] :
                                            CompatibleColors[activeFog.Note];

                    // Check if normally retrieved beam is usable
                    if (!ShouldRandomize && Array.IndexOf(compColorTable, GetBeamNote(midiNote.Note)) >= 0)
                    {
                        beamNote = GetBeamNote(midiNote.Note);
                    }
                    else
                    {
                        int index = ShouldRandomize ? Randomizer.Next(0, compColorTable.Length) : midiNote.Note % compColorTable.Length;
                        beamNote = compColorTable[index];
                    }
                }
                else
                {
                    beamNote = ShouldRandomize ? GetRandomBeamNote(previousNote) : GetBeamNote(midiNote.Note);
                }

                if (beamNote == previousNote)
                {
                    continue;
                }

                yield return(new ShowLight(midiNote.Time, beamNote));

                previousNote = beamNote;
                previousTime = midiNote.Time;
            }

            // Turn beams off during noguitar sections (Skip last section (END))
            foreach (var ngSection in sections.Where(s => s.Name == "noguitar").SkipLast())
            {
                yield return(new ShowLight(ngSection.Time, ShowLight.BeamOff));
            }
        }