2017-02-13 03:38:05 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-02-16 12:37:08 +08:00
|
|
|
|
using System;
|
2017-02-13 03:38:05 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2017-02-16 12:37:08 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-09-06 16:02:13 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Judgements;
|
2017-02-13 03:38:05 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
2017-02-13 03:38:05 +08:00
|
|
|
|
{
|
|
|
|
|
public class DrawableSliderTick : DrawableOsuHitObject
|
|
|
|
|
{
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly SliderTick sliderTick;
|
2017-02-13 03:38:05 +08:00
|
|
|
|
|
|
|
|
|
public double FadeInTime;
|
|
|
|
|
public double FadeOutTime;
|
|
|
|
|
|
2017-02-16 16:02:36 +08:00
|
|
|
|
public bool Tracking;
|
2017-02-13 03:38:05 +08:00
|
|
|
|
|
2017-10-09 19:17:05 +08:00
|
|
|
|
public override bool DisplayJudgement => false;
|
|
|
|
|
|
2017-02-13 03:38:05 +08:00
|
|
|
|
public DrawableSliderTick(SliderTick sliderTick) : base(sliderTick)
|
|
|
|
|
{
|
|
|
|
|
this.sliderTick = sliderTick;
|
|
|
|
|
|
|
|
|
|
Size = new Vector2(16) * sliderTick.Scale;
|
|
|
|
|
|
|
|
|
|
Masking = true;
|
|
|
|
|
CornerRadius = Size.X / 2;
|
|
|
|
|
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
|
|
BorderThickness = 2;
|
|
|
|
|
BorderColour = Color4.White;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-03-23 14:37:16 +08:00
|
|
|
|
Colour = AccentColour,
|
2017-02-13 03:38:05 +08:00
|
|
|
|
Alpha = 0.3f,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-06 16:02:13 +08:00
|
|
|
|
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
2017-02-13 03:38:05 +08:00
|
|
|
|
{
|
2017-09-06 16:02:13 +08:00
|
|
|
|
if (timeOffset >= 0)
|
2017-09-12 23:37:18 +08:00
|
|
|
|
AddJudgement(new OsuJudgement { Result = Tracking ? HitResult.Great : HitResult.Miss });
|
2017-02-13 03:38:05 +08:00
|
|
|
|
}
|
2017-04-06 16:21:18 +08:00
|
|
|
|
|
2017-02-13 03:38:05 +08:00
|
|
|
|
protected override void UpdatePreemptState()
|
|
|
|
|
{
|
|
|
|
|
var animIn = Math.Min(150, sliderTick.StartTime - FadeInTime);
|
|
|
|
|
|
2017-07-17 21:51:21 +08:00
|
|
|
|
this.Animate(
|
|
|
|
|
d => d.FadeIn(animIn),
|
|
|
|
|
d => d.ScaleTo(0.5f).ScaleTo(1.2f, animIn)
|
|
|
|
|
).Then(
|
2017-07-23 02:50:25 +08:00
|
|
|
|
d => d.ScaleTo(1, 150, Easing.Out)
|
2017-07-17 21:51:21 +08:00
|
|
|
|
);
|
2017-02-13 03:38:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-27 16:37:38 +08:00
|
|
|
|
protected override void UpdateCurrentState(ArmedState state)
|
2017-02-13 03:38:05 +08:00
|
|
|
|
{
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Idle:
|
2017-07-17 22:05:24 +08:00
|
|
|
|
this.Delay(FadeOutTime - sliderTick.StartTime).FadeOut();
|
2017-02-13 03:38:05 +08:00
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Miss:
|
2017-07-17 22:05:24 +08:00
|
|
|
|
this.FadeOut(160)
|
|
|
|
|
.FadeColour(Color4.Red, 80);
|
2017-02-13 03:38:05 +08:00
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Hit:
|
2017-07-23 02:50:25 +08:00
|
|
|
|
this.FadeOut(120, Easing.OutQuint)
|
|
|
|
|
.ScaleTo(Scale * 1.5f, 120, Easing.OutQuint);
|
2017-02-13 03:38:05 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-27 16:37:38 +08:00
|
|
|
|
}
|