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; osuObject = h;
Origin = Anchor.Centre; Origin = Anchor.Centre;
Position = osuObject.Position + h.StackOffset; Position = osuObject.StackedPosition;
Scale = new Vector2(osuObject.Scale); Scale = new Vector2(osuObject.Scale);
Children = new Drawable[] Children = new Drawable[]

View File

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

View File

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

View File

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

View File

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