1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 11:27:24 +08:00

Refactor SliderBody into its own class.

This commit is contained in:
Dean Herbert 2016-11-28 17:05:30 +09:00
parent 622c90daf7
commit 9eb3e1168e

View File

@ -11,10 +11,11 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{ {
class DrawableSlider : DrawableOsuHitObject class DrawableSlider : DrawableOsuHitObject
{ {
private Path path;
private DrawableHitCircle startCircle;
private Slider slider; private Slider slider;
private DrawableHitCircle startCircle;
private Container ball; private Container ball;
private SliderBody body;
public DrawableSlider(Slider s) : base(s) public DrawableSlider(Slider s) : base(s)
{ {
@ -25,10 +26,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
Children = new Drawable[] Children = new Drawable[]
{ {
path = new Path body = new SliderBody(s),
{
Colour = s.Colour,
},
ball = new Container ball = new Container
{ {
Masking = true, Masking = true,
@ -61,14 +59,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{ {
base.LoadComplete(); base.LoadComplete();
path.PathWidth = startCircle.DrawWidth / 4;
//force application of the state that was set before we loaded. //force application of the state that was set before we loaded.
UpdateState(State); UpdateState(State);
} }
double snakeDrawn = 0;
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
@ -84,6 +78,62 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
t = 1 - t; t = 1 - t;
} }
ball.Position = slider.Curve.PositionAt(t);
}
protected override void UpdateState(ArmedState state)
{
if (!IsLoaded) return;
Flush(true); //move to DrawableHitObject
Alpha = 0;
Delay(HitObject.StartTime - 450 - Time.Current, true);
FadeIn(300);
Delay(450 + HitObject.Duration);
FadeOut(100);
}
class SliderBody : Container
{
private Path path;
double snakeDrawn = 0;
Slider slider;
public SliderBody(Slider s)
{
slider = s;
Children = new Drawable[]
{
//new BufferedContainer
//{
// RelativeSizeAxes = Axes.Both,
// Children = new Drawable[]
// {
path = new Path
{
Colour = s.Colour,
},
// }
//}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
path.PathWidth = 50;
}
protected override void Update()
{
base.Update();
double snake = MathHelper.Clamp((Time.Current - slider.StartTime + 450) / 200, 0, 1); double snake = MathHelper.Clamp((Time.Current - slider.StartTime + 450) / 200, 0, 1);
if (snake != snakeDrawn) if (snake != snakeDrawn)
{ {
@ -105,23 +155,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
snakeDrawn = snake; snakeDrawn = snake;
path.Positions.Add(slider.Curve.PositionAt(snake)); path.Positions.Add(slider.Curve.PositionAt(snake));
} }
ball.Position = slider.Curve.PositionAt(t);
} }
protected override void UpdateState(ArmedState state)
{
if (!IsLoaded) return;
Flush(true); //move to DrawableHitObject
Alpha = 0;
Delay(HitObject.StartTime - 450 - Time.Current, true);
FadeIn(200);
Delay(450 + HitObject.Duration);
FadeOut(100);
} }
} }
} }