diff --git a/osu.Game.Rulesets.Osu/Judgements/OsuSliderTailJudgement.cs b/osu.Game.Rulesets.Osu/Judgements/OsuSliderTailJudgement.cs new file mode 100644 index 0000000000..a6e67ea979 --- /dev/null +++ b/osu.Game.Rulesets.Osu/Judgements/OsuSliderTailJudgement.cs @@ -0,0 +1,13 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Rulesets.Scoring; + +namespace osu.Game.Rulesets.Osu.Judgements +{ + public class OsuSliderTailJudgement : OsuJudgement + { + public override bool AffectsCombo => false; + protected override int NumericResultFor(HitResult result) => 0; + } +} diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs index af947817c0..5f464402d0 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs @@ -18,14 +18,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables public class DrawableSlider : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach { private readonly Slider slider; - - public readonly DrawableHitCircle InitialCircle; - private readonly List components = new List(); - private readonly Container ticks; - private readonly Container repeatPoints; - + public readonly DrawableHitCircle HeadCircle; public readonly SliderBody Body; public readonly SliderBall Ball; @@ -34,6 +29,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { slider = s; + DrawableSliderTail tail; + Container ticks; + Container repeatPoints; + Children = new Drawable[] { Body = new SliderBody(s) @@ -51,27 +50,17 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables AlwaysPresent = true, Alpha = 0 }, - InitialCircle = new DrawableHitCircle(new HitCircle - { - StartTime = s.StartTime, - Position = s.StackedPosition, - IndexInCurrentCombo = s.IndexInCurrentCombo, - Scale = s.Scale, - ComboColour = s.ComboColour, - Samples = s.Samples, - SampleControlPoint = s.SampleControlPoint, - TimePreempt = s.TimePreempt, - TimeFadein = s.TimeFadein, - HitWindow300 = s.HitWindow300, - HitWindow100 = s.HitWindow100, - HitWindow50 = s.HitWindow50 - }) + HeadCircle = new DrawableHitCircle(s.HeadCircle), + tail = new DrawableSliderTail(s.TailCircle) }; components.Add(Body); components.Add(Ball); - AddNested(InitialCircle); + AddNested(HeadCircle); + + AddNested(tail); + components.Add(tail); foreach (var tick in s.NestedHitObjects.OfType()) { @@ -87,6 +76,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables }; ticks.Add(drawableTick); + components.Add(drawableTick); AddNested(drawableTick); } @@ -121,27 +111,25 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables currentSpan = span; //todo: we probably want to reconsider this before adding scoring, but it looks and feels nice. - if (!InitialCircle.Judgements.Any(j => j.IsHit)) - InitialCircle.Position = slider.Curve.PositionAt(progress); + if (!HeadCircle.IsHit) + HeadCircle.Position = slider.Curve.PositionAt(progress); foreach (var c in components.OfType()) c.UpdateProgress(progress, span); foreach (var c in components.OfType()) c.UpdateSnakingPosition(slider.Curve.PositionAt(Body.SnakedStart ?? 0), slider.Curve.PositionAt(Body.SnakedEnd ?? 0)); - foreach (var t in ticks.Children) t.Tracking = Ball.Tracking; + foreach (var t in components.OfType()) t.Tracking = Ball.Tracking; } protected override void CheckForJudgements(bool userTriggered, double timeOffset) { if (!userTriggered && Time.Current >= slider.EndTime) { - var judgementsCount = ticks.Children.Count + repeatPoints.Children.Count + 1; - var judgementsHit = ticks.Children.Count(t => t.Judgements.Any(j => j.IsHit)) + repeatPoints.Children.Count(t => t.Judgements.Any(j => j.IsHit)); - if (InitialCircle.Judgements.Any(j => j.IsHit)) - judgementsHit++; + var judgementsCount = NestedHitObjects.Count; + var judgementsHit = NestedHitObjects.Count(h => h.IsHit); var hitFraction = (double)judgementsHit / judgementsCount; - if (hitFraction == 1 && InitialCircle.Judgements.Any(j => j.Result == HitResult.Great)) + if (hitFraction == 1 && HeadCircle.Judgements.Any(j => j.Result == HitResult.Great)) AddJudgement(new OsuJudgement { Result = HitResult.Great }); - else if (hitFraction >= 0.5 && InitialCircle.Judgements.Any(j => j.Result >= HitResult.Good)) + else if (hitFraction >= 0.5 && HeadCircle.Judgements.Any(j => j.Result >= HitResult.Good)) AddJudgement(new OsuJudgement { Result = HitResult.Good }); else if (hitFraction > 0) AddJudgement(new OsuJudgement { Result = HitResult.Meh }); @@ -173,7 +161,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables } } - public Drawable ProxiedLayer => InitialCircle.ApproachCircle; + public Drawable ProxiedLayer => HeadCircle.ApproachCircle; public override Vector2 SelectionPoint => ToScreenSpace(Body.Position); public override Quad SelectionQuad => Body.PathDrawQuad; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs new file mode 100644 index 0000000000..8835fc2b29 --- /dev/null +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs @@ -0,0 +1,32 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Game.Rulesets.Osu.Judgements; +using osu.Game.Rulesets.Scoring; + +namespace osu.Game.Rulesets.Osu.Objects.Drawables +{ + public class DrawableSliderTail : DrawableOsuHitObject, IRequireTracking + { + /// + /// The judgement text is provided by the . + /// + public override bool DisplayJudgement => false; + + public bool Tracking { get; set; } + + public DrawableSliderTail(HitCircle hitCircle) + : base(hitCircle) + { + AlwaysPresent = true; + RelativeSizeAxes = Axes.Both; + } + + protected override void CheckForJudgements(bool userTriggered, double timeOffset) + { + if (!userTriggered && timeOffset >= 0) + AddJudgement(new OsuSliderTailJudgement { Result = Tracking ? HitResult.Great : HitResult.Miss }); + } + } +} diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs index 09985752a4..ae76f1e0e1 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs @@ -12,14 +12,14 @@ using osu.Game.Rulesets.Scoring; namespace osu.Game.Rulesets.Osu.Objects.Drawables { - public class DrawableSliderTick : DrawableOsuHitObject + public class DrawableSliderTick : DrawableOsuHitObject, IRequireTracking { private readonly SliderTick sliderTick; public double FadeInTime; public double FadeOutTime; - public bool Tracking; + public bool Tracking { get; set; } public override bool DisplayJudgement => false; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/IRequireTracking.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/IRequireTracking.cs new file mode 100644 index 0000000000..98fc686dd3 --- /dev/null +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/IRequireTracking.cs @@ -0,0 +1,13 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Rulesets.Osu.Objects.Drawables +{ + public interface IRequireTracking + { + /// + /// Whether the is currently being tracked by the user. + /// + bool Tracking { get; set; } + } +} diff --git a/osu.Game.Rulesets.Osu/Objects/Slider.cs b/osu.Game.Rulesets.Osu/Objects/Slider.cs index 79bb14a475..d4444c5c5d 100644 --- a/osu.Game.Rulesets.Osu/Objects/Slider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Slider.cs @@ -80,6 +80,9 @@ namespace osu.Game.Rulesets.Osu.Objects public double Velocity; public double TickDistance; + public HitCircle HeadCircle; + public HitCircle TailCircle; + protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) { base.ApplyDefaultsToSelf(controlPointInfo, difficulty); @@ -97,10 +100,37 @@ namespace osu.Game.Rulesets.Osu.Objects { base.CreateNestedHitObjects(); + createSliderEnds(); createTicks(); createRepeatPoints(); } + private void createSliderEnds() + { + HeadCircle = new HitCircle + { + StartTime = StartTime, + Position = StackedPosition, + IndexInCurrentCombo = IndexInCurrentCombo, + ComboColour = ComboColour, + Samples = Samples, + SampleControlPoint = SampleControlPoint + }; + + TailCircle = new HitCircle + { + StartTime = EndTime, + Position = StackedEndPosition, + IndexInCurrentCombo = IndexInCurrentCombo, + ComboColour = ComboColour, + Samples = Samples, + SampleControlPoint = SampleControlPoint + }; + + AddNested(HeadCircle); + AddNested(TailCircle); + } + private void createTicks() { if (TickDistance == 0) return; diff --git a/osu.Game.Rulesets.Osu/Tests/TestCaseSlider.cs b/osu.Game.Rulesets.Osu/Tests/TestCaseSlider.cs index 5060137ec6..2d26b74d01 100644 --- a/osu.Game.Rulesets.Osu/Tests/TestCaseSlider.cs +++ b/osu.Game.Rulesets.Osu/Tests/TestCaseSlider.cs @@ -16,6 +16,9 @@ using OpenTK; using OpenTK.Graphics; using osu.Game.Rulesets.Mods; using System.Linq; +using osu.Game.Graphics.Sprites; +using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; namespace osu.Game.Rulesets.Osu.Tests @@ -142,7 +145,34 @@ namespace osu.Game.Rulesets.Osu.Tests foreach (var mod in Mods.OfType()) mod.ApplyToDrawableHitObjects(new[] { drawable }); + drawable.OnJudgement += onJudgement; + Add(drawable); } + + private float judgementOffsetDirection = 1; + private void onJudgement(DrawableHitObject judgedObject, Judgement judgement) + { + var osuObject = judgedObject as DrawableOsuHitObject; + if (osuObject == null) + return; + + OsuSpriteText text; + Add(text = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Text = judgement.IsHit ? "Hit!" : "Miss!", + Colour = judgement.IsHit ? Color4.Green : Color4.Red, + TextSize = 30, + Position = osuObject.HitObject.StackedEndPosition + judgementOffsetDirection * new Vector2(0, 45) + }); + + text.Delay(150) + .Then().FadeOut(200) + .Then().Expire(); + + judgementOffsetDirection *= -1; + } } } diff --git a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj index 74a3883f0a..97a003513f 100644 --- a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj +++ b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj @@ -55,6 +55,7 @@ + @@ -75,6 +76,8 @@ + + diff --git a/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs b/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs index f236182939..755800c4e1 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs @@ -8,6 +8,8 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Timing; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Edit.Layers.Selection; using osu.Game.Rulesets.Osu.Edit; using osu.Game.Rulesets.Osu.Objects; @@ -35,9 +37,9 @@ namespace osu.Game.Tests.Visual new SelectionLayer(playfield) }; - playfield.Add(new DrawableHitCircle(new HitCircle { Position = new Vector2(256, 192), Scale = 0.5f })); - playfield.Add(new DrawableHitCircle(new HitCircle { Position = new Vector2(344, 148), Scale = 0.5f })); - playfield.Add(new DrawableSlider(new Slider + var hitCircle1 = new HitCircle { Position = new Vector2(256, 192), Scale = 0.5f }; + var hitCircle2 = new HitCircle { Position = new Vector2(344, 148), Scale = 0.5f }; + var slider = new Slider { ControlPoints = new List { @@ -48,8 +50,16 @@ namespace osu.Game.Tests.Visual Position = new Vector2(128, 256), Velocity = 1, TickDistance = 100, - Scale = 0.5f - })); + Scale = 0.5f, + }; + + hitCircle1.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); + hitCircle2.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); + slider.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); + + playfield.Add(new DrawableHitCircle(hitCircle1)); + playfield.Add(new DrawableHitCircle(hitCircle2)); + playfield.Add(new DrawableSlider(slider)); } } } diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 8f72644b28..231250e858 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -240,13 +240,13 @@ namespace osu.Game.Rulesets.UI foreach (var mod in Mods.OfType()) mod.ApplyToDifficulty(Beatmap.BeatmapInfo.BaseDifficulty); + // Post-process the beatmap + processor.PostProcess(Beatmap); + // Apply defaults foreach (var h in Beatmap.HitObjects) h.ApplyDefaults(Beatmap.ControlPointInfo, Beatmap.BeatmapInfo.BaseDifficulty); - // Post-process the beatmap - processor.PostProcess(Beatmap); - KeyBindingInputManager = CreateInputManager(); KeyBindingInputManager.RelativeSizeAxes = Axes.Both;