diff --git a/osu.Game.Modes.Osu/Objects/Drawables/FollowPoint.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs similarity index 93% rename from osu.Game.Modes.Osu/Objects/Drawables/FollowPoint.cs rename to osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs index 22ffead4d9..b0b63d17b9 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/FollowPoint.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPoint.cs @@ -9,7 +9,7 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Transformations; -namespace osu.Game.Modes.Osu.Objects.Drawables +namespace osu.Game.Modes.Osu.Objects.Drawables.Connections { public class FollowPoint : Container { diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs new file mode 100644 index 0000000000..78c875d874 --- /dev/null +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs @@ -0,0 +1,65 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Game.Modes.Objects.Drawables; +using osu.Game.Modes.Osu.Objects.Drawables.Connections; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace osu.Game.Modes.Osu.Objects.Drawables +{ + public class FollowPointConnection : HitObjectConnection + { + public int PointDistance = 32; + public int PreEmpt = 800; + + public override void AddConnections(IEnumerable drawableHitObjects, int startIndex = 0, int endIndex = -1) + { + var hitObjects = new List(drawableHitObjects + .Select(d => (OsuHitObject)d.HitObject) + .OrderBy(h => h.StartTime)); + + if (endIndex < 0) + endIndex = hitObjects.Count - 1; + + for (int i = startIndex + 1; i <= endIndex; i++) + { + var prevHitObject = hitObjects[i - 1]; + var currHitObject = hitObjects[i]; + + if (!currHitObject.NewCombo && !(prevHitObject is Spinner) && !(currHitObject is Spinner)) + { + Vector2 startPosition = prevHitObject.EndPosition; + Vector2 endPosition = currHitObject.Position; + double startTime = prevHitObject.EndTime; + double endTime = currHitObject.StartTime; + + Vector2 distanceVector = endPosition - startPosition; + int distance = (int)distanceVector.Length; + float rotation = (float)Math.Atan2(distanceVector.Y, distanceVector.X); + double duration = endTime - startTime; + + for (int d = (int)(PointDistance * 1.5); d < distance - PointDistance; d += PointDistance) + { + float fraction = ((float)d / distance); + Vector2 pointStartPosition = startPosition + (fraction - 0.1f) * distanceVector; + Vector2 pointEndPosition = startPosition + fraction * distanceVector; + double fadeOutTime = startTime + fraction * duration; + double fadeInTime = fadeOutTime - PreEmpt; + + Add(new FollowPoint() + { + StartTime = fadeInTime, + EndTime = fadeOutTime, + Position = pointStartPosition, + EndPosition = pointEndPosition, + Rotation = rotation, + }); + } + } + } + } + } +} diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs new file mode 100644 index 0000000000..d8c91f23df --- /dev/null +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.Containers; +using osu.Game.Modes.Objects.Drawables; +using System.Collections.Generic; + +namespace osu.Game.Modes.Osu.Objects.Drawables.Connections +{ + public abstract class HitObjectConnection : Container + { + public abstract void AddConnections(IEnumerable drawableHitObjects, int startIndex = 0, int endIndex = -1); + } +} diff --git a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs index 1be73a0452..ef7b36b0bd 100644 --- a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs @@ -7,10 +7,8 @@ using osu.Framework.Graphics.Containers; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects.Drawables; +using osu.Game.Modes.Osu.Objects.Drawables.Connections; using osu.Game.Modes.UI; -using System; -using System.Collections.Generic; -using System.Linq; namespace osu.Game.Modes.Osu.UI { @@ -18,7 +16,7 @@ namespace osu.Game.Modes.Osu.UI { private Container approachCircles; private Container judgementLayer; - private Container followPointsLayer; + private HitObjectConnection hitObjectConnection; public override Vector2 Size { @@ -40,7 +38,7 @@ namespace osu.Game.Modes.Osu.UI Add(new Drawable[] { - followPointsLayer = new Container + hitObjectConnection = new FollowPointConnection { RelativeSizeAxes = Axes.Both, Depth = 1, @@ -74,7 +72,7 @@ namespace osu.Game.Modes.Osu.UI public override void PostProcess() { - AddFollowPoints(); + hitObjectConnection.AddConnections(HitObjects.Children); } private void judgement(DrawableHitObject h, JudgementInfo j) @@ -83,58 +81,5 @@ namespace osu.Game.Modes.Osu.UI judgementLayer.Add(explosion); } - - public void AddFollowPoints(int startIndex = 0, int endIndex = -1) - { - var followLineDistance = 32; - var followLinePreEmpt = 800; - - var hitObjects = new List(HitObjects.Children - .Select(d => (OsuHitObject)d.HitObject) - .OrderBy(h => h.StartTime)); - - if (endIndex < 0) - endIndex = hitObjects.Count - 1; - - for (int i = startIndex + 1; i <= endIndex; i++) - { - var prevHitObject = hitObjects[i - 1]; - var currHitObject = hitObjects[i]; - - if (prevHitObject.StartTime > currHitObject.StartTime) - throw new Exception(); - - if (!currHitObject.NewCombo && !(prevHitObject is Spinner) && !(currHitObject is Spinner)) - { - Vector2 startPosition = prevHitObject.EndPosition; - Vector2 endPosition = currHitObject.Position; - double startTime = prevHitObject.EndTime; - double endTime = currHitObject.StartTime; - - Vector2 distanceVector = endPosition - startPosition; - int distance = (int)distanceVector.Length; - float rotation = (float)Math.Atan2(distanceVector.Y, distanceVector.X); - double duration = endTime - startTime; - - for (int d = (int)(followLineDistance * 1.5); d < distance - followLineDistance; d += followLineDistance) - { - float fraction = ((float)d / distance); - Vector2 pointStartPosition = startPosition + (fraction - 0.1f) * distanceVector; - Vector2 pointEndPosition = startPosition + fraction * distanceVector; - double fadeOutTime = startTime + fraction * duration; - double fadeInTime = fadeOutTime - followLinePreEmpt; - - followPointsLayer.Add(new FollowPoint() - { - StartTime = fadeInTime, - EndTime = fadeOutTime, - Position = pointStartPosition, - EndPosition = pointEndPosition, - Rotation = rotation, - }); - } - } - } - } } } \ No newline at end of file diff --git a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj index 88d25cb8f4..567eec593c 100644 --- a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj @@ -44,10 +44,12 @@ + + - +