1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 19:22:55 +08:00
osu-lazer/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableBarLine.cs

80 lines
2.4 KiB
C#
Raw Normal View History

2017-03-21 19:39:18 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using OpenTK;
2017-04-18 15:05:58 +08:00
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
2017-03-21 19:39:18 +08:00
{
/// <summary>
/// A line that scrolls alongside hit objects in the playfield and visualises control points.
/// </summary>
public class DrawableBarLine : Container
{
2017-04-03 09:04:13 +08:00
/// <summary>
/// The width of the line tracker.
/// </summary>
private const float tracker_width = 2f;
/// <summary>
/// Fade out time calibrated to a pre-empt of 1000ms.
/// </summary>
private const float base_fadeout_time = 100f;
2017-03-21 19:39:18 +08:00
/// <summary>
2017-04-02 01:06:58 +08:00
/// The visual line tracker.
2017-03-21 19:39:18 +08:00
/// </summary>
protected Box Tracker;
/// <summary>
2017-04-02 01:06:58 +08:00
/// The bar line.
2017-03-21 19:39:18 +08:00
/// </summary>
protected readonly BarLine BarLine;
public DrawableBarLine(BarLine barLine)
{
BarLine = barLine;
Anchor = Anchor.CentreLeft;
Origin = Anchor.Centre;
RelativePositionAxes = Axes.X;
RelativeSizeAxes = Axes.Y;
2017-04-03 09:04:13 +08:00
Width = tracker_width;
2017-03-21 19:39:18 +08:00
Children = new[]
{
Tracker = new Box
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
EdgeSmoothness = new Vector2(0.5f, 0),
Alpha = 0.75f
}
};
2017-04-05 18:58:57 +08:00
LifetimeStart = BarLine.StartTime - BarLine.ScrollTime * 2;
LifetimeEnd = BarLine.StartTime + BarLine.ScrollTime;
2017-03-21 19:39:18 +08:00
}
protected override void LoadComplete()
{
base.LoadComplete();
2017-03-21 20:27:20 +08:00
Delay(BarLine.StartTime - Time.Current);
2017-04-05 10:48:30 +08:00
FadeOut(base_fadeout_time * BarLine.ScrollTime / 1000);
2017-03-21 19:39:18 +08:00
}
2017-04-05 10:48:30 +08:00
private void updateScrollPosition(double time) => MoveToX((float)((BarLine.StartTime - time) / BarLine.ScrollTime));
2017-03-21 19:39:18 +08:00
protected override void Update()
{
base.Update();
2017-04-02 01:06:58 +08:00
updateScrollPosition(Time.Current);
2017-03-21 19:39:18 +08:00
}
}
}