osu/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs

76 lines
2.4 KiB
C#
Raw Normal View History

2018-01-05 11:21:19 +00:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
2017-02-12 19:38:05 +00:00
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
2017-04-18 07:05:58 +00:00
using osu.Game.Rulesets.Objects.Drawables;
2017-02-16 04:37:08 +00:00
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Scoring;
2017-02-12 19:38:05 +00:00
2017-04-18 07:05:58 +00:00
namespace osu.Game.Rulesets.Osu.Objects.Drawables
2017-02-12 19:38:05 +00:00
{
public class DrawableSliderTick : DrawableOsuHitObject, IRequireTracking
2017-02-12 19:38:05 +00:00
{
2018-02-11 10:03:01 +00:00
public const double ANIM_DURATION = 150;
2017-02-12 19:38:05 +00:00
public bool Tracking { get; set; }
2017-02-12 19:38:05 +00:00
public override bool DisplayJudgement => false;
2017-02-12 19:38:05 +00:00
public DrawableSliderTick(SliderTick sliderTick) : base(sliderTick)
{
Size = new Vector2(16) * sliderTick.Scale;
Masking = true;
CornerRadius = Size.X / 2;
Origin = Anchor.Centre;
BorderThickness = 2;
BorderColour = Color4.White;
InternalChildren = new Drawable[]
2017-02-12 19:38:05 +00:00
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = AccentColour,
2017-02-12 19:38:05 +00:00
Alpha = 0.3f,
}
};
}
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
2017-02-12 19:38:05 +00:00
{
if (timeOffset >= 0)
AddJudgement(new OsuJudgement { Result = Tracking ? HitResult.Great : HitResult.Miss });
2017-02-12 19:38:05 +00:00
}
2017-02-12 19:38:05 +00:00
protected override void UpdatePreemptState()
{
2018-03-06 08:33:42 +00:00
this.FadeOut().FadeIn(ANIM_DURATION);
this.ScaleTo(0.5f).ScaleTo(1f, ANIM_DURATION * 4, Easing.OutElasticHalf);
2017-02-12 19:38:05 +00:00
}
protected override void UpdateCurrentState(ArmedState state)
2017-02-12 19:38:05 +00:00
{
switch (state)
{
case ArmedState.Idle:
2018-01-25 09:52:03 +00:00
this.Delay(HitObject.TimePreempt).FadeOut();
2017-02-12 19:38:05 +00:00
break;
case ArmedState.Miss:
2018-03-06 08:33:42 +00:00
this.FadeOut(ANIM_DURATION);
this.FadeColour(Color4.Red, ANIM_DURATION / 2);
2017-02-12 19:38:05 +00:00
break;
case ArmedState.Hit:
2018-03-06 08:33:42 +00:00
this.FadeOut(ANIM_DURATION, Easing.OutQuint);
this.ScaleTo(Scale * 1.5f, ANIM_DURATION, Easing.Out);
2017-02-12 19:38:05 +00:00
break;
}
}
}
}