1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 01:02:55 +08:00

Add StackedPosition/StackedEndPosition and offset slider curves by StackOffset.

This commit is contained in:
Damnae 2017-02-09 08:29:21 +01:00
parent 38b25a7df3
commit a79fde897b
6 changed files with 32 additions and 13 deletions

View File

@ -28,7 +28,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
osuObject = h;
Origin = Anchor.Centre;
Position = osuObject.Position + h.StackOffset;
Position = osuObject.StackedPosition;
Scale = new Vector2(osuObject.Scale);
Children = new Drawable[]

View File

@ -31,7 +31,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{
body = new SliderBody(s)
{
Position = s.Position + s.StackOffset,
Position = s.StackedPosition,
PathWidth = s.Scale * 64,
},
bouncer1 = new SliderBouncer(s, false)
@ -41,7 +41,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
},
bouncer2 = new SliderBouncer(s, true)
{
Position = s.Position + s.StackOffset,
Position = s.StackedPosition,
Scale = new Vector2(s.Scale),
},
ball = new SliderBall(s)
@ -51,7 +51,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
initialCircle = new DrawableHitCircle(new HitCircle
{
StartTime = s.StartTime,
Position = s.Position + s.StackOffset,
Position = s.StackedPosition,
Scale = s.Scale,
Colour = s.Colour,
Sample = s.Sample,
@ -89,11 +89,11 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
if (repeat % 2 == 1)
progress = 1 - progress;
bouncer2.Position = slider.Curve.PositionAt(body.SnakedEnd ?? 0) + slider.StackOffset;
bouncer2.Position = slider.Curve.PositionAt(body.SnakedEnd ?? 0);
//todo: we probably want to reconsider this before adding scoring, but it looks and feels nice.
if (initialCircle.Judgement?.Result != HitResult.Hit)
initialCircle.Position = slider.Curve.PositionAt(progress) + slider.StackOffset;
initialCircle.Position = slider.Curve.PositionAt(progress);
components.ForEach(c => c.UpdateProgress(progress, repeat));
}

View File

@ -26,7 +26,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
Direction = FlowDirection.VerticalOnly;
Spacing = new Vector2(0, 2);
Position = (h?.EndPosition ?? Vector2.Zero) + judgement.PositionOffset;
Position = (h?.StackedEndPosition ?? Vector2.Zero) + judgement.PositionOffset;
Children = new Drawable[]
{

View File

@ -13,13 +13,18 @@ namespace osu.Game.Modes.Osu.Objects
{
public Vector2 Position { get; set; }
public float Scale { get; set; } = 1;
public Vector2 StackedPosition => Position + StackOffset;
public virtual Vector2 EndPosition => Position;
public int StackHeight { get; set; }
public Vector2 StackedEndPosition => EndPosition + StackOffset;
public virtual int StackHeight { get; set; }
public Vector2 StackOffset => new Vector2(StackHeight * Scale * -6.4f);
public float Scale { get; set; } = 1;
public override void SetDefaultsFromBeatmap(Beatmap beatmap)
{
base.SetDefaultsFromBeatmap(beatmap);

View File

@ -12,6 +12,18 @@ namespace osu.Game.Modes.Osu.Objects
public override Vector2 EndPosition => RepeatCount % 2 == 0 ? Position : Curve.PositionAt(1);
private int stackHeight;
public override int StackHeight
{
get { return stackHeight; }
set
{
stackHeight = value;
if (Curve != null)
Curve.Offset = StackOffset;
}
}
public double Velocity;
public override void SetDefaultsFromBeatmap(Beatmap beatmap)

View File

@ -17,6 +17,8 @@ namespace osu.Game.Modes.Osu.Objects
public CurveTypes CurveType;
public Vector2 Offset;
private List<Vector2> calculatedPath = new List<Vector2>();
private List<double> cumulativeLength = new List<double>();
@ -177,12 +179,12 @@ namespace osu.Game.Modes.Osu.Objects
int i = 0;
for (; i < calculatedPath.Count && cumulativeLength[i] < d0; ++i);
path.Add(interpolateVertices(i, d0));
path.Add(interpolateVertices(i, d0) + Offset);
for (; i < calculatedPath.Count && cumulativeLength[i] <= d1; ++i)
path.Add(calculatedPath[i]);
path.Add(calculatedPath[i] + Offset);
path.Add(interpolateVertices(i, d1));
path.Add(interpolateVertices(i, d1) + Offset);
}
/// <summary>
@ -194,7 +196,7 @@ namespace osu.Game.Modes.Osu.Objects
public Vector2 PositionAt(double progress)
{
double d = progressToDistance(progress);
return interpolateVertices(indexOfDistance(d), d);
return interpolateVertices(indexOfDistance(d), d) + Offset;
}
}
}