From d11e5d0060f88b6fd78a1dcad7d5ac1e9280b512 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 12:53:45 +0900 Subject: [PATCH] Add hit windows to Note/HoldNote. --- .../Judgements/HitWindows.cs | 162 ++++++++++++++++++ osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 23 ++- .../Objects/ManiaHitObject.cs | 1 + osu.Game.Rulesets.Mania/Objects/Note.cs | 12 ++ .../Objects/{ => Types}/IHasColumn.cs | 2 +- .../osu.Game.Rulesets.Mania.csproj | 3 +- 6 files changed, 200 insertions(+), 3 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/Judgements/HitWindows.cs rename osu.Game.Rulesets.Mania/Objects/{ => Types}/IHasColumn.cs (79%) diff --git a/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs new file mode 100644 index 0000000000..a1354314bf --- /dev/null +++ b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs @@ -0,0 +1,162 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Database; + +namespace osu.Game.Rulesets.Mania.Judgements +{ + public class HitWindows + { + #region Constants + + /// + /// PERFECT hit window at OD = 10. + /// + private const double perfect_min = 27.8; + /// + /// PERFECT hit window at OD = 5. + /// + private const double perfect_mid = 38.8; + /// + /// PERFECT hit window at OD = 0. + /// + private const double perfect_max = 44.8; + + /// + /// GREAT hit window at OD = 10. + /// + private const double great_min = 68; + /// + /// GREAT hit window at OD = 5. + /// + private const double great_mid = 98; + /// + /// GREAT hit window at OD = 0. + /// + private const double great_max = 128; + + /// + /// GOOD hit window at OD = 10. + /// + private const double good_min = 134; + /// + /// GOOD hit window at OD = 5. + /// + private const double good_mid = 164; + /// + /// GOOD hit window at OD = 0. + /// + private const double good_max = 194; + + /// + /// OK hit window at OD = 10. + /// + private const double ok_min = 194; + /// + /// OK hit window at OD = 5. + /// + private const double ok_mid = 224; + /// + /// OK hit window at OD = 0. + /// + private const double ok_max = 254; + + /// + /// BAD hit window at OD = 10. + /// + private const double bad_min = 242; + /// + /// BAD hit window at OD = 5. + /// + private const double bad_mid = 272; + /// + /// BAD hit window at OD = 0. + /// + private const double bad_max = 302; + + /// + /// MISS hit window at OD = 10. + /// + private const double miss_min = 316; + /// + /// MISS hit window at OD = 5. + /// + private const double miss_mid = 346; + /// + /// MISS hit window at OD = 0. + /// + private const double miss_max = 376; + + #endregion + + /// + /// Hit window for a PERFECT hit. + /// + public double Perfect = perfect_mid; + + /// + /// Hit window for a GREAT hit. + /// + public double Great = great_mid; + + /// + /// Hit window for a GOOD hit. + /// + public double Good = good_mid; + + /// + /// Hit window for an OK hit. + /// + public double Ok = ok_mid; + + /// + /// Hit window for a BAD hit. + /// + public double Bad = bad_mid; + + /// + /// Hit window for a MISS hit. + /// + public double Miss = miss_mid; + + public HitWindows() + { + } + + public HitWindows(double difficulty) + { + Perfect = BeatmapDifficulty.DifficultyRange(difficulty, perfect_max, perfect_mid, perfect_min); + Great = BeatmapDifficulty.DifficultyRange(difficulty, great_max, great_mid, great_min); + Good = BeatmapDifficulty.DifficultyRange(difficulty, good_max, good_mid, good_min); + Ok = BeatmapDifficulty.DifficultyRange(difficulty, ok_max, ok_mid, ok_min); + Bad = BeatmapDifficulty.DifficultyRange(difficulty, bad_max, bad_mid, bad_min); + Miss = BeatmapDifficulty.DifficultyRange(difficulty, miss_max, miss_mid, miss_min); + } + + public static HitWindows operator *(HitWindows windows, double value) + { + return new HitWindows + { + Perfect = windows.Perfect * value, + Great = windows.Great * value, + Good = windows.Good * value, + Ok = windows.Ok * value, + Bad = windows.Bad * value, + Miss = windows.Miss * value + }; + } + + public static HitWindows operator /(HitWindows windows, double value) + { + return new HitWindows + { + Perfect = windows.Perfect / value, + Great = windows.Great / value, + Good = windows.Good / value, + Ok = windows.Ok / value, + Bad = windows.Bad / value, + Miss = windows.Miss / value + }; + } + } +} diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index e8ce1da77f..e32eb3f147 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -1,9 +1,30 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Game.Beatmaps.Timing; +using osu.Game.Database; +using osu.Game.Rulesets.Mania.Judgements; +using osu.Game.Rulesets.Objects.Types; + namespace osu.Game.Rulesets.Mania.Objects { - public class HoldNote : Note + public class HoldNote : Note, IHasEndTime { + /// + /// Lenience of release hit windows. + /// + private const double release_window_lenience = 1.5; + + public double Duration { get; set; } + public double EndTime => StartTime + Duration; + + public HitWindows ReleaseHitWindows { get; protected set; } = new HitWindows(); + + public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) + { + base.ApplyDefaults(timing, difficulty); + + ReleaseHitWindows = HitWindows * release_window_lenience; + } } } diff --git a/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs index e991c1ad93..93aaa94f45 100644 --- a/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Game.Rulesets.Mania.Objects.Types; using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Objects diff --git a/osu.Game.Rulesets.Mania/Objects/Note.cs b/osu.Game.Rulesets.Mania/Objects/Note.cs index 2cc993df64..83299ba7be 100644 --- a/osu.Game.Rulesets.Mania/Objects/Note.cs +++ b/osu.Game.Rulesets.Mania/Objects/Note.cs @@ -1,9 +1,21 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Game.Beatmaps.Timing; +using osu.Game.Database; +using osu.Game.Rulesets.Mania.Judgements; + namespace osu.Game.Rulesets.Mania.Objects { public class Note : ManiaHitObject { + public HitWindows HitWindows { get; protected set; } = new HitWindows(); + + public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) + { + base.ApplyDefaults(timing, difficulty); + + HitWindows = new HitWindows(difficulty.OverallDifficulty); + } } } diff --git a/osu.Game.Rulesets.Mania/Objects/IHasColumn.cs b/osu.Game.Rulesets.Mania/Objects/Types/IHasColumn.cs similarity index 79% rename from osu.Game.Rulesets.Mania/Objects/IHasColumn.cs rename to osu.Game.Rulesets.Mania/Objects/Types/IHasColumn.cs index daf7d217cd..7b98b2b4bb 100644 --- a/osu.Game.Rulesets.Mania/Objects/IHasColumn.cs +++ b/osu.Game.Rulesets.Mania/Objects/Types/IHasColumn.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Rulesets.Mania.Objects +namespace osu.Game.Rulesets.Mania.Objects.Types { public interface IHasColumn { diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 49331bf598..46a006b09c 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -48,9 +48,10 @@ + - +