2019-01-24 08:43:03 +00: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 09:19:50 +00:00
|
|
|
|
|
2019-07-25 04:42:29 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-07-29 18:42:05 +00:00
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|
|
|
|
{
|
|
|
|
|
public class DrawableSliderTick : DrawableOsuHitObject, IRequireTracking
|
|
|
|
|
{
|
|
|
|
|
public const double ANIM_DURATION = 150;
|
|
|
|
|
|
2019-07-25 04:42:29 +00:00
|
|
|
|
private const float default_tick_size = 16;
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
public bool Tracking { get; set; }
|
|
|
|
|
|
2018-08-06 02:31:46 +00:00
|
|
|
|
public override bool DisplayResult => false;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-12-03 11:03:39 +00:00
|
|
|
|
protected DrawableSlider DrawableSlider => (DrawableSlider)ParentHitObject;
|
|
|
|
|
|
2020-11-05 04:51:46 +00:00
|
|
|
|
private SkinnableDrawable scaleContainer;
|
2019-07-25 04:42:29 +00:00
|
|
|
|
|
2020-11-12 06:59:48 +00:00
|
|
|
|
public DrawableSliderTick()
|
|
|
|
|
: base(null)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-28 04:31:40 +00:00
|
|
|
|
public DrawableSliderTick(SliderTick sliderTick)
|
|
|
|
|
: base(sliderTick)
|
2020-11-05 04:51:46 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-07-25 04:42:29 +00:00
|
|
|
|
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
2019-08-30 05:39:02 +00:00
|
|
|
|
InternalChild = scaleContainer = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderScorePoint), _ => new CircularContainer
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-07-25 04:42:29 +00:00
|
|
|
|
Masking = true,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Size = new Vector2(default_tick_size),
|
|
|
|
|
BorderThickness = default_tick_size / 4,
|
|
|
|
|
BorderColour = Color4.White,
|
|
|
|
|
Child = new Box
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-07-25 04:42:29 +00:00
|
|
|
|
Colour = AccentColour.Value,
|
|
|
|
|
Alpha = 0.3f,
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2018-04-13 09:19:50 +00:00
|
|
|
|
};
|
2019-07-25 04:42:29 +00:00
|
|
|
|
|
2020-11-12 06:59:48 +00:00
|
|
|
|
ScaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue));
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-03 10:46:42 +00:00
|
|
|
|
protected override void OnApply()
|
|
|
|
|
{
|
|
|
|
|
base.OnApply();
|
|
|
|
|
|
2020-12-03 11:03:39 +00:00
|
|
|
|
Position = HitObject.Position - DrawableSlider.HitObject.Position;
|
2019-07-25 04:42:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-06 02:31:46 +00:00
|
|
|
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
if (timeOffset >= 0)
|
2020-09-29 05:35:43 +00:00
|
|
|
|
ApplyResult(r => r.Type = Tracking ? r.Judgement.MaxResult : r.Judgement.MinResult);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-22 06:33:12 +00:00
|
|
|
|
protected override void UpdateInitialTransforms()
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
this.FadeOut().FadeIn(ANIM_DURATION);
|
|
|
|
|
this.ScaleTo(0.5f).ScaleTo(1f, ANIM_DURATION * 4, Easing.OutElasticHalf);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-04 07:19:07 +00:00
|
|
|
|
protected override void UpdateHitStateTransforms(ArmedState state)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2020-11-04 07:19:07 +00:00
|
|
|
|
base.UpdateHitStateTransforms(state);
|
2019-09-13 09:49:21 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Idle:
|
|
|
|
|
this.Delay(HitObject.TimePreempt).FadeOut();
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
case ArmedState.Miss:
|
|
|
|
|
this.FadeOut(ANIM_DURATION);
|
|
|
|
|
this.FadeColour(Color4.Red, ANIM_DURATION / 2);
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
case ArmedState.Hit:
|
|
|
|
|
this.FadeOut(ANIM_DURATION, Easing.OutQuint);
|
|
|
|
|
this.ScaleTo(Scale * 1.5f, ANIM_DURATION, Easing.Out);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|