1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 18:53:21 +08:00

Fix the math

This commit is contained in:
Andrei Zavatski 2019-08-18 02:49:07 +03:00
parent f7024b513e
commit 906984ad95

View File

@ -16,6 +16,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using System.Linq;
namespace osu.Game.Screens.Play.HUD namespace osu.Game.Screens.Play.HUD
{ {
@ -30,6 +31,9 @@ namespace osu.Game.Screens.Play.HUD
[Resolved] [Resolved]
private Bindable<WorkingBeatmap> beatmap { get; set; } private Bindable<WorkingBeatmap> beatmap { get; set; }
[Resolved]
private OsuColour colours { get; set; }
private readonly bool mirrored; private readonly bool mirrored;
private readonly SpriteIcon arrow; private readonly SpriteIcon arrow;
private readonly FillFlowContainer bar; private readonly FillFlowContainer bar;
@ -60,50 +64,46 @@ namespace osu.Game.Screens.Play.HUD
}; };
} }
[BackgroundDependencyLoader] protected override void LoadComplete()
private void load(OsuColour colours)
{ {
base.LoadComplete();
HitWindows.SetDifficulty(beatmap.Value.BeatmapInfo.BaseDifficulty.OverallDifficulty);
bar.AddRange(new Drawable[] bar.AddRange(new Drawable[]
{ {
new Box new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientVertical(colours.Yellow.Opacity(0), colours.Yellow), Colour = ColourInfo.GradientVertical(colours.Yellow.Opacity(0), colours.Yellow),
Height = 0.3f Height = (float)((HitWindows.Meh - HitWindows.Good) / (HitWindows.Meh * 2))
}, },
new Box new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = colours.Green, Colour = colours.Green,
Height = 0.15f Height = (float)((HitWindows.Good - HitWindows.Great) / (HitWindows.Meh * 2))
}, },
new Box new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = colours.BlueLight, Colour = colours.BlueLight,
Height = 0.1f Height = (float)(HitWindows.Great / HitWindows.Meh)
}, },
new Box new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = colours.Green, Colour = colours.Green,
Height = 0.15f Height = (float)((HitWindows.Good - HitWindows.Great) / (HitWindows.Meh * 2))
}, },
new Box new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientVertical(colours.Yellow, colours.Yellow.Opacity(0)), Colour = ColourInfo.GradientVertical(colours.Yellow, colours.Yellow.Opacity(0)),
Height = 0.3f Height = (float)((HitWindows.Meh - HitWindows.Good) / (HitWindows.Meh * 2))
} }
}); });
} }
protected override void LoadComplete()
{
base.LoadComplete();
HitWindows.SetDifficulty(beatmap.Value.BeatmapInfo.BaseDifficulty.OverallDifficulty);
}
public void OnNewJudgement(JudgementResult judgement) public void OnNewJudgement(JudgementResult judgement)
{ {
if (!judgement.IsHit) if (!judgement.IsHit)
@ -135,7 +135,7 @@ namespace osu.Game.Screens.Play.HUD
} }
}; };
private float getRelativeJudgementPosition(double value) => (float)(value / HitWindows.Miss); private float getRelativeJudgementPosition(double value) => (float)(value / HitWindows.Meh);
private double calculateArrowPosition(JudgementResult judgement) private double calculateArrowPosition(JudgementResult judgement)
{ {
@ -144,12 +144,7 @@ namespace osu.Game.Screens.Play.HUD
judgementOffsets.Add(judgement.TimeOffset); judgementOffsets.Add(judgement.TimeOffset);
double offsets = 0; return judgementOffsets.Average();
foreach (var offset in judgementOffsets)
offsets += offset;
return offsets / judgementOffsets.Count;
} }
} }
} }