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-16 12:39:01 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
|
using osu.Framework.Audio.Sample;
|
2017-02-13 03:38:05 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2017-02-25 20:12:39 +08:00
|
|
|
|
using osu.Framework.Graphics.Transforms;
|
2017-02-16 12:39:01 +08:00
|
|
|
|
using osu.Game.Beatmaps.Samples;
|
2017-02-13 03:38:05 +08:00
|
|
|
|
using osu.Game.Modes.Objects.Drawables;
|
2017-02-16 12:37:08 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
2017-02-13 03:38:05 +08:00
|
|
|
|
|
2017-02-16 12:37:08 +08:00
|
|
|
|
namespace osu.Game.Modes.Osu.Objects.Drawables
|
2017-02-13 03:38:05 +08:00
|
|
|
|
{
|
|
|
|
|
public class DrawableSliderTick : DrawableOsuHitObject
|
|
|
|
|
{
|
|
|
|
|
private SliderTick sliderTick;
|
|
|
|
|
|
|
|
|
|
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-02-14 23:12:35 +08:00
|
|
|
|
public override bool RemoveWhenNotAlive => false;
|
|
|
|
|
|
2017-03-07 09:59:19 +08:00
|
|
|
|
protected override JudgementInfo CreateJudgementInfo() => new OsuJudgementInfo { MaxScore = OsuScoreResult.SliderTick };
|
2017-02-16 16:33:13 +08:00
|
|
|
|
|
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-13 18:15:25 +08:00
|
|
|
|
Colour = sliderTick.ComboColour,
|
2017-02-13 03:38:05 +08:00
|
|
|
|
Alpha = 0.3f,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-18 16:35:04 +08:00
|
|
|
|
private SampleChannel sample;
|
2017-02-16 12:39:01 +08:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(AudioManager audio)
|
|
|
|
|
{
|
|
|
|
|
string sampleSet = (HitObject.Sample?.Set ?? SampleSet.Normal).ToString().ToLower();
|
|
|
|
|
|
|
|
|
|
sample = audio.Sample.Get($@"Gameplay/{sampleSet}-slidertick");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PlaySample()
|
|
|
|
|
{
|
|
|
|
|
sample?.Play();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-02-13 03:38:05 +08:00
|
|
|
|
protected override void CheckJudgement(bool userTriggered)
|
|
|
|
|
{
|
2017-03-07 09:59:19 +08:00
|
|
|
|
var j = (OsuJudgementInfo)Judgement;
|
2017-02-16 16:02:36 +08:00
|
|
|
|
|
2017-02-13 03:38:05 +08:00
|
|
|
|
if (Judgement.TimeOffset >= 0)
|
2017-02-16 16:02:36 +08:00
|
|
|
|
{
|
|
|
|
|
j.Result = Tracking ? HitResult.Hit : HitResult.Miss;
|
|
|
|
|
j.Score = Tracking ? OsuScoreResult.SliderTick : OsuScoreResult.Miss;
|
|
|
|
|
}
|
2017-02-13 03:38:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdatePreemptState()
|
|
|
|
|
{
|
|
|
|
|
var animIn = Math.Min(150, sliderTick.StartTime - FadeInTime);
|
|
|
|
|
|
|
|
|
|
ScaleTo(0.5f);
|
|
|
|
|
ScaleTo(1.2f, animIn);
|
|
|
|
|
FadeIn(animIn);
|
|
|
|
|
|
|
|
|
|
Delay(animIn);
|
|
|
|
|
ScaleTo(1, 150, EasingTypes.Out);
|
|
|
|
|
|
|
|
|
|
Delay(-animIn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateState(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
if (!IsLoaded) return;
|
|
|
|
|
|
|
|
|
|
base.UpdateState(state);
|
|
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Idle:
|
|
|
|
|
Delay(FadeOutTime - sliderTick.StartTime);
|
|
|
|
|
FadeOut();
|
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Miss:
|
2017-02-16 12:33:59 +08:00
|
|
|
|
FadeOut(160);
|
|
|
|
|
FadeColour(Color4.Red, 80);
|
2017-02-13 03:38:05 +08:00
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Hit:
|
2017-02-16 12:33:59 +08:00
|
|
|
|
FadeOut(120, EasingTypes.OutQuint);
|
|
|
|
|
ScaleTo(Scale * 1.5f, 120, EasingTypes.OutQuint);
|
2017-02-13 03:38:05 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|