mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 21:12:55 +08:00
Calculate real position for judgement lines
This commit is contained in:
parent
0a255fe4d1
commit
2a35c3c3e2
@ -9,6 +9,10 @@ using osuTK.Graphics;
|
|||||||
using osuTK;
|
using osuTK;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play.HUD
|
namespace osu.Game.Screens.Play.HUD
|
||||||
{
|
{
|
||||||
@ -18,6 +22,11 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
private const int bar_height = 250;
|
private const int bar_height = 250;
|
||||||
private const int spacing = 3;
|
private const int spacing = 3;
|
||||||
|
|
||||||
|
public HitWindows HitWindows { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private Bindable<WorkingBeatmap> beatmap { get; set; }
|
||||||
|
|
||||||
private readonly bool mirrored;
|
private readonly bool mirrored;
|
||||||
private readonly SpriteIcon arrow;
|
private readonly SpriteIcon arrow;
|
||||||
private readonly List<double> judgementOffsets = new List<double>();
|
private readonly List<double> judgementOffsets = new List<double>();
|
||||||
@ -47,6 +56,12 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
HitWindows.SetDifficulty(beatmap.Value.BeatmapInfo.BaseDifficulty.OverallDifficulty);
|
||||||
|
}
|
||||||
|
|
||||||
public void OnNewJudgement(JudgementResult judgement)
|
public void OnNewJudgement(JudgementResult judgement)
|
||||||
{
|
{
|
||||||
Container judgementLine;
|
Container judgementLine;
|
||||||
@ -56,7 +71,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
judgementLine.FadeOut(5000, Easing.OutQuint);
|
judgementLine.FadeOut(5000, Easing.OutQuint);
|
||||||
judgementLine.Expire();
|
judgementLine.Expire();
|
||||||
|
|
||||||
arrow.MoveToY(calculateArrowPosition(judgement) / bar_height, 500, Easing.OutQuint);
|
arrow.MoveToY(getRelativeJudgementPosition(calculateArrowPosition(judgement)), 500, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual Container CreateJudgementLine(JudgementResult judgement) => new CircularContainer
|
protected virtual Container CreateJudgementLine(JudgementResult judgement) => new CircularContainer
|
||||||
@ -66,7 +81,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
Masking = true,
|
Masking = true,
|
||||||
Size = new Vector2(10, 2),
|
Size = new Vector2(10, 2),
|
||||||
RelativePositionAxes = Axes.Y,
|
RelativePositionAxes = Axes.Y,
|
||||||
Y = (float)judgement.TimeOffset / bar_height,
|
Y = getRelativeJudgementPosition(judgement.TimeOffset),
|
||||||
X = mirrored ? spacing : -spacing,
|
X = mirrored ? spacing : -spacing,
|
||||||
Child = new Box
|
Child = new Box
|
||||||
{
|
{
|
||||||
@ -75,7 +90,9 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private float calculateArrowPosition(JudgementResult judgement)
|
private float getRelativeJudgementPosition(double value) => (float)(value / HitWindows.Miss);
|
||||||
|
|
||||||
|
private double calculateArrowPosition(JudgementResult judgement)
|
||||||
{
|
{
|
||||||
if (judgementOffsets.Count > 5)
|
if (judgementOffsets.Count > 5)
|
||||||
judgementOffsets.RemoveAt(0);
|
judgementOffsets.RemoveAt(0);
|
||||||
@ -87,7 +104,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
foreach (var offset in judgementOffsets)
|
foreach (var offset in judgementOffsets)
|
||||||
offsets += offset;
|
offsets += offset;
|
||||||
|
|
||||||
return (float)offsets / judgementOffsets.Count;
|
return offsets / judgementOffsets.Count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,10 +277,16 @@ namespace osu.Game.Screens.Play
|
|||||||
HealthDisplay?.Current.BindTo(processor.Health);
|
HealthDisplay?.Current.BindTo(processor.Health);
|
||||||
|
|
||||||
if (LeftAccuracyBar != null)
|
if (LeftAccuracyBar != null)
|
||||||
|
{
|
||||||
processor.NewJudgement += LeftAccuracyBar.OnNewJudgement;
|
processor.NewJudgement += LeftAccuracyBar.OnNewJudgement;
|
||||||
|
LeftAccuracyBar.HitWindows = processor.CreateHitWindows();
|
||||||
|
}
|
||||||
|
|
||||||
if (RightAccuracyBar != null)
|
if (RightAccuracyBar != null)
|
||||||
|
{
|
||||||
processor.NewJudgement += RightAccuracyBar.OnNewJudgement;
|
processor.NewJudgement += RightAccuracyBar.OnNewJudgement;
|
||||||
|
RightAccuracyBar.HitWindows = processor.CreateHitWindows();
|
||||||
|
}
|
||||||
|
|
||||||
if (HealthDisplay is StandardHealthDisplay shd)
|
if (HealthDisplay is StandardHealthDisplay shd)
|
||||||
processor.NewJudgement += shd.Flash;
|
processor.NewJudgement += shd.Flash;
|
||||||
|
Loading…
Reference in New Issue
Block a user