mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 09:07:25 +08:00
Refactor SliderBody into its own class.
This commit is contained in:
parent
622c90daf7
commit
9eb3e1168e
@ -11,10 +11,11 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
{
|
||||
class DrawableSlider : DrawableOsuHitObject
|
||||
{
|
||||
private Path path;
|
||||
private DrawableHitCircle startCircle;
|
||||
private Slider slider;
|
||||
|
||||
private DrawableHitCircle startCircle;
|
||||
private Container ball;
|
||||
private SliderBody body;
|
||||
|
||||
public DrawableSlider(Slider s) : base(s)
|
||||
{
|
||||
@ -25,10 +26,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
path = new Path
|
||||
{
|
||||
Colour = s.Colour,
|
||||
},
|
||||
body = new SliderBody(s),
|
||||
ball = new Container
|
||||
{
|
||||
Masking = true,
|
||||
@ -61,14 +59,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
path.PathWidth = startCircle.DrawWidth / 4;
|
||||
|
||||
//force application of the state that was set before we loaded.
|
||||
UpdateState(State);
|
||||
}
|
||||
|
||||
double snakeDrawn = 0;
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
@ -84,6 +78,62 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
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);
|
||||
if (snake != snakeDrawn)
|
||||
{
|
||||
@ -105,23 +155,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
snakeDrawn = 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user