2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-10-02 12:41:22 +08:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2020-10-02 12:41:22 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Skinning;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|
|
|
|
{
|
2020-10-02 12:41:22 +08:00
|
|
|
|
public class DrawableSliderTail : DrawableOsuHitObject, IRequireTracking, ITrackSnaking
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-10-29 14:36:43 +08:00
|
|
|
|
private readonly Slider slider;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The judgement text is provided by the <see cref="DrawableSlider"/>.
|
|
|
|
|
/// </summary>
|
2018-08-06 10:31:46 +08:00
|
|
|
|
public override bool DisplayResult => false;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
public bool Tracking { get; set; }
|
|
|
|
|
|
2020-10-02 12:41:22 +08:00
|
|
|
|
private readonly IBindable<float> scaleBindable = new BindableFloat();
|
|
|
|
|
|
|
|
|
|
private readonly SkinnableDrawable circlePiece;
|
|
|
|
|
|
|
|
|
|
private readonly Container scaleContainer;
|
2018-11-09 12:58:46 +08:00
|
|
|
|
|
2018-08-01 20:46:22 +08:00
|
|
|
|
public DrawableSliderTail(Slider slider, SliderTailCircle hitCircle)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
: base(hitCircle)
|
|
|
|
|
{
|
2018-10-29 14:36:43 +08:00
|
|
|
|
this.slider = slider;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
2020-10-02 12:41:22 +08:00
|
|
|
|
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-10-02 12:41:22 +08:00
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
scaleContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
// no default for this; only visible in legacy skins.
|
|
|
|
|
circlePiece = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderTailHitCircle), _ => Empty())
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-10-02 12:41:22 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
scaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue), true);
|
|
|
|
|
scaleBindable.BindTo(HitObject.ScaleBindable);
|
|
|
|
|
}
|
2018-11-14 13:29:22 +08:00
|
|
|
|
|
2020-10-02 12:41:22 +08:00
|
|
|
|
protected override void UpdateInitialTransforms()
|
|
|
|
|
{
|
|
|
|
|
base.UpdateInitialTransforms();
|
2019-10-08 16:56:56 +08:00
|
|
|
|
|
2020-10-02 12:41:22 +08:00
|
|
|
|
circlePiece.FadeInFromZero(HitObject.TimeFadeIn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateStateTransforms(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
base.UpdateStateTransforms(state);
|
|
|
|
|
|
|
|
|
|
Debug.Assert(HitObject.HitWindows != null);
|
|
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Idle:
|
|
|
|
|
this.Delay(HitObject.TimePreempt).FadeOut(500);
|
|
|
|
|
|
|
|
|
|
Expire(true);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ArmedState.Miss:
|
|
|
|
|
this.FadeOut(100);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ArmedState.Hit:
|
|
|
|
|
// todo: temporary / arbitrary
|
|
|
|
|
this.Delay(800).FadeOut();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-06 10:31:46 +08:00
|
|
|
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
if (!userTriggered && timeOffset >= 0)
|
2020-09-29 13:35:43 +08:00
|
|
|
|
ApplyResult(r => r.Type = Tracking ? r.Judgement.MaxResult : r.Judgement.MinResult);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2018-10-29 14:36:43 +08:00
|
|
|
|
|
2020-10-02 12:41:22 +08:00
|
|
|
|
public void UpdateSnakingPosition(Vector2 start, Vector2 end)
|
|
|
|
|
{
|
|
|
|
|
Position = end;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|