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
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-07-30 02:42:05 +08:00
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|
|
|
|
{
|
|
|
|
|
public class DrawableSliderTick : DrawableOsuHitObject, IRequireTracking
|
|
|
|
|
{
|
|
|
|
|
public const double ANIM_DURATION = 150;
|
|
|
|
|
|
|
|
|
|
public bool Tracking { get; set; }
|
|
|
|
|
|
2018-08-06 10:31:46 +08:00
|
|
|
|
public override bool DisplayResult => false;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
public DrawableSliderTick(SliderTick sliderTick) : base(sliderTick)
|
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(16) * sliderTick.Scale;
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
2018-07-30 02:42:05 +08:00
|
|
|
|
new SkinnableDrawable("Play/osu/sliderscorepoint", _ => new Container
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-30 02:42:05 +08:00
|
|
|
|
Masking = true,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2018-07-30 02:42:05 +08:00
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
CornerRadius = Size.X / 2,
|
|
|
|
|
|
|
|
|
|
BorderThickness = 2,
|
|
|
|
|
BorderColour = Color4.White,
|
|
|
|
|
|
|
|
|
|
Child = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = AccentColour,
|
|
|
|
|
Alpha = 0.3f,
|
|
|
|
|
}
|
|
|
|
|
}, restrictSize: false)
|
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 (timeOffset >= 0)
|
2018-08-03 14:38:48 +08:00
|
|
|
|
ApplyResult(r => r.Type = Tracking ? HitResult.Great : HitResult.Miss);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdatePreemptState()
|
|
|
|
|
{
|
|
|
|
|
this.FadeOut().FadeIn(ANIM_DURATION);
|
|
|
|
|
this.ScaleTo(0.5f).ScaleTo(1f, ANIM_DURATION * 4, Easing.OutElasticHalf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateCurrentState(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Idle:
|
|
|
|
|
this.Delay(HitObject.TimePreempt).FadeOut();
|
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Miss:
|
|
|
|
|
this.FadeOut(ANIM_DURATION);
|
|
|
|
|
this.FadeColour(Color4.Red, ANIM_DURATION / 2);
|
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Hit:
|
|
|
|
|
this.FadeOut(ANIM_DURATION, Easing.OutQuint);
|
|
|
|
|
this.ScaleTo(Scale * 1.5f, ANIM_DURATION, Easing.Out);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|