osu/osu.Game.Mode.Osu/Objects/Drawables/DrawableSlider.cs

71 lines
1.9 KiB
C#
Raw Normal View History

2016-11-17 12:29:35 +00:00
using osu.Framework.Graphics;
2016-11-28 03:40:24 +00:00
using osu.Framework.Graphics.Containers;
2016-11-17 12:29:35 +00:00
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Osu.Objects.Drawables.Pieces;
using OpenTK;
using osu.Framework.Graphics.Sprites;
2016-11-28 03:40:24 +00:00
using OpenTK.Graphics;
namespace osu.Game.Modes.Osu.Objects.Drawables
{
class DrawableSlider : DrawableOsuHitObject
{
2016-11-28 03:40:24 +00:00
private Path path;
private DrawableHitCircle startCircle;
private Slider slider;
public DrawableSlider(Slider s) : base(s)
{
2016-11-28 03:40:24 +00:00
slider = s;
2016-11-28 03:40:24 +00:00
Origin = Anchor.TopLeft;
Position = Vector2.Zero;
2016-11-28 03:40:24 +00:00
Children = new Drawable[]
{
2016-11-28 03:40:24 +00:00
startCircle = new DrawableHitCircle(new HitCircle
{
StartTime = s.StartTime,
Position = s.Position,
Colour = s.Colour,
})
{
Depth = 1 //override time-based depth.
},
path = new Path
{
Colour = s.Colour,
}
};
2016-11-17 12:29:35 +00:00
}
protected override void LoadComplete()
{
base.LoadComplete();
2016-11-28 07:28:47 +00:00
for (int i = 0; i < slider.Curve.Length; i += 10)
path.Positions.Add(slider.Curve.PositionAt(i / slider.Curve.Length));
2016-11-28 03:40:24 +00:00
path.PathWidth = startCircle.DrawWidth / 4;
2016-11-17 12:29:35 +00:00
//force application of the state that was set before we loaded.
UpdateState(State);
}
protected override void UpdateState(ArmedState state)
{
2016-11-17 12:29:35 +00:00
if (!IsLoaded) return;
Flush(true); //move to DrawableHitObject
Alpha = 0;
Delay(HitObject.StartTime - 450 - Time.Current, true);
2016-11-17 12:29:35 +00:00
FadeIn(200);
Delay(450 + HitObject.Duration);
2016-11-17 12:29:35 +00:00
FadeOut(200);
}
}
}