コード例 #1
0
        public static SongScore AnalyzeMap(BSMap map)
        {
            int len = (int)BSMath.Ceiling(map.Data.Notes.Max(x => (float?)x.Time) ?? 0);

            if (len == 0)
            {
                return(new SongScore(average: 0, max: 0, graph: Array.Empty <AggregatedHit>()));
            }

            var scoredRed  = ProcessColor(map, NoteColor.Red);
            var scoredBlue = ProcessColor(map, NoteColor.Blue);

            var timedRed  = ConvertToFixedTimeBlocks(scoredRed, len);
            var timedBlue = ConvertToFixedTimeBlocks(scoredBlue, len);

            var combined = new AggregatedHit[len];

            for (int i = 0; i < len; i++)
            {
                int cnt = timedRed[i].HitDifficulty > 0 && timedBlue[i].HitDifficulty > 0 ? 2 : 1;
                combined[i] = (timedRed[i] + timedBlue[i]) / cnt;
            }

            var totalDifficulty = combined.Select(h => h.TotalDifficulty()).ToList();

            return(new SongScore
                   (
                       average: totalDifficulty.Average(),
                       max: totalDifficulty.Max(),
                       graph: combined
                   ));
        }
コード例 #2
0
        public static AggregatedHit[] ConvertToFixedTimeBlocks(IEnumerable <ScoredClusterHit> notes, int len)
        {
            var timed = new AggregatedHit[len];

            foreach (ScoredClusterHit note in notes)
            {
                int timeIndex = (int)note.Cluster.BeatTime;
                if (timeIndex < 0 || timeIndex >= len)
                {
                    continue;
                }
                timed[timeIndex] = new AggregatedHit(Math.Max(timed[timeIndex].HitDifficulty, note.HitDifficulty),
                                                     Math.Max(timed[timeIndex].ContinuousDifficulty, note.ContinuousDifficulty), note.Cluster.RealTime);
            }

            return(timed);
        }