Beispiel #1
0
        public void GeneratePhraseIterationsData(IAttributes attribute, dynamic song, GameVersion gameVersion)
        {
            if (song.PhraseIterations == null)
            {
                return;
            }

            for (int i = 0; i < song.PhraseIterations.Length; i++)
            {
                var phraseIteration = song.PhraseIterations[i];
                var phrase          = song.Phrases[phraseIteration.PhraseId];
                var endTime         = i >= song.PhraseIterations.Length - 1 ? song.SongLength : song.PhraseIterations[i + 1].Time;

                var phraseIt = new PhraseIteration();
                phraseIt.StartTime     = phraseIteration.Time;
                phraseIt.EndTime       = endTime;
                phraseIt.PhraseIndex   = phraseIteration.PhraseId;
                phraseIt.Name          = phrase.Name;
                phraseIt.MaxDifficulty = phrase.MaxDifficulty;

                if (gameVersion == GameVersion.RS2012)
                {
                    phraseIt.MaxScorePerDifficulty = new List <float>();
                }

                attribute.PhraseIterations.Add(phraseIt);
            }

            var noteCnt = 0;

            foreach (var y in attribute.PhraseIterations)
            {
                if (song.Levels[y.MaxDifficulty].Notes != null)
                {
                    if (gameVersion == GameVersion.RS2012)
                    {
                        noteCnt += GetNoteCount(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes);
                    }
                    else
                    {
                        noteCnt += GetNoteCount2014(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes);
                    }
                }
                if (song.Levels[y.MaxDifficulty].Chords != null)
                {
                    noteCnt += GetChordCount(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Chords);
                }
            }

            attribute.Score_MaxNotes = noteCnt;
            attribute.Score_PNV      = ((float)attribute.TargetScore) / noteCnt;

            foreach (var y in attribute.PhraseIterations)
            {
                var phrase = song.Phrases[y.PhraseIndex];
                for (int o = 0; o <= phrase.MaxDifficulty; o++)
                {
                    var multiplier = ((float)(o + 1)) / (phrase.MaxDifficulty + 1);
                    var pnv        = attribute.Score_PNV;
                    var noteCount  = 0;

                    if (song.Levels[o].Chords != null)
                    {
                        if (gameVersion == GameVersion.RS2012)
                        {
                            noteCnt += GetNoteCount(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes);
                        }
                        else
                        {
                            noteCnt += GetNoteCount2014(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes);
                        }
                    }

                    if (song.Levels[o].Chords != null)
                    {
                        noteCount += GetChordCount(y.StartTime, y.EndTime, song.Levels[o].Chords);
                    }

                    if (gameVersion == GameVersion.RS2012)
                    {
                        var score = pnv * noteCount * multiplier;
                        y.MaxScorePerDifficulty.Add(score);
                    }
                }
            }
        }
        private void GeneratePhraseIterationsData(Attributes attribute, Song song)
        {
            if (song.PhraseIterations == null)
            {
                return;
            }
            for (int i = 0; i < song.PhraseIterations.Length; i++)
            {

                var phraseIteration = song.PhraseIterations[i];
                var phrase = song.Phrases[phraseIteration.PhraseId];
                var endTime = i >= song.PhraseIterations.Length - 1 ? song.SongLength : song.PhraseIterations[i + 1].Time;
                var phraseIt = new PhraseIteration
                {
                    StartTime = phraseIteration.Time,
                    EndTime = endTime,
                    PhraseIndex = phraseIteration.PhraseId,
                    Name = phrase.Name,
                    MaxDifficulty = phrase.MaxDifficulty,
                    MaxScorePerDifficulty = new List<float>()
                };
                attribute.PhraseIterations.Add(phraseIt);
            }
            var noteCnt = 0;
            foreach (var y in attribute.PhraseIterations)
            {
                if (song.Levels[y.MaxDifficulty].Notes != null)
                {
                    noteCnt += GetNoteCount(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes);
                }
                if (song.Levels[y.MaxDifficulty].Chords != null )
                {
                    noteCnt += GetChordCount(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Chords);
                }
            }
            attribute.Score_MaxNotes = noteCnt;
            attribute.Score_PNV = ((float)attribute.TargetScore) / noteCnt;

            foreach (var y in attribute.PhraseIterations)
            {
                var phrase = song.Phrases[y.PhraseIndex];
                for (int o = 0; o <= phrase.MaxDifficulty; o++)
                {
                    var multiplier = ((float)(o + 1)) / (phrase.MaxDifficulty + 1);
                    var pnv = attribute.Score_PNV;
                    var noteCount = 0;
                    if (song.Levels[o].Chords != null)
                    {
                        noteCount += GetNoteCount(y.StartTime, y.EndTime, song.Levels[o].Notes);
                    }
                    if (song.Levels[o].Chords != null)
                    {
                        noteCount += GetChordCount(y.StartTime, y.EndTime, song.Levels[o].Chords);
                    }
                    var score = pnv * noteCount * multiplier;
                    y.MaxScorePerDifficulty.Add(score);
                }
            }
        }