2018-01-05 11:21:19 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-09-26 16:13:34 +00:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System;
|
2018-01-23 10:31:37 +00:00
|
|
|
|
using System.Linq;
|
2017-09-26 16:13:34 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Judgements;
|
2017-12-30 20:23:18 +00:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2017-09-26 16:13:34 +00:00
|
|
|
|
|
2017-09-26 16:21:39 +00:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
2017-09-26 16:13:34 +00:00
|
|
|
|
{
|
2018-01-18 12:06:47 +00:00
|
|
|
|
public class DrawableRepeatPoint : DrawableOsuHitObject, ITrackSnaking
|
2017-09-26 16:13:34 +00:00
|
|
|
|
{
|
2017-09-27 15:28:44 +00:00
|
|
|
|
private readonly RepeatPoint repeatPoint;
|
2017-09-26 16:13:34 +00:00
|
|
|
|
private readonly DrawableSlider drawableSlider;
|
2018-01-24 21:41:51 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Are we located in the last ControlPoint of our <see cref="DrawableSlider.CurrentCurve"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
private bool isRepeatAtEnd => repeatPoint.RepeatIndex % 2 == 0;
|
2017-09-26 16:13:34 +00:00
|
|
|
|
|
2018-01-22 11:36:38 +00:00
|
|
|
|
private double animDuration;
|
2017-09-26 16:13:34 +00:00
|
|
|
|
|
2017-11-03 06:30:46 +00:00
|
|
|
|
public DrawableRepeatPoint(RepeatPoint repeatPoint, DrawableSlider drawableSlider)
|
|
|
|
|
: base(repeatPoint)
|
2017-09-26 16:13:34 +00:00
|
|
|
|
{
|
2017-09-27 15:28:44 +00:00
|
|
|
|
this.repeatPoint = repeatPoint;
|
2017-09-26 16:13:34 +00:00
|
|
|
|
this.drawableSlider = drawableSlider;
|
|
|
|
|
|
2018-01-23 10:31:37 +00:00
|
|
|
|
Size = new Vector2(45 * repeatPoint.Scale);
|
2017-12-30 08:05:40 +00:00
|
|
|
|
|
2017-09-26 16:13:34 +00:00
|
|
|
|
Blending = BlendingMode.Additive;
|
|
|
|
|
Origin = Anchor.Centre;
|
2018-01-24 21:34:52 +00:00
|
|
|
|
|
2017-09-26 16:13:34 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new SpriteIcon
|
|
|
|
|
{
|
2017-12-30 08:05:40 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2018-01-23 10:31:37 +00:00
|
|
|
|
Icon = FontAwesome.fa_chevron_right
|
2017-09-26 16:13:34 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
|
|
|
|
{
|
2017-09-27 15:28:44 +00:00
|
|
|
|
if (repeatPoint.StartTime <= Time.Current)
|
2017-09-26 16:13:34 +00:00
|
|
|
|
AddJudgement(new OsuJudgement { Result = drawableSlider.Tracking ? HitResult.Great : HitResult.Miss });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdatePreemptState()
|
|
|
|
|
{
|
2018-01-23 08:04:45 +00:00
|
|
|
|
animDuration = Math.Min(150, repeatPoint.SpanDuration / 2);
|
2017-09-26 16:13:34 +00:00
|
|
|
|
|
2018-01-22 11:36:38 +00:00
|
|
|
|
this.FadeIn(animDuration).ScaleTo(1.2f, animDuration / 2)
|
2017-11-03 06:29:16 +00:00
|
|
|
|
.Then()
|
2018-01-22 11:36:38 +00:00
|
|
|
|
.ScaleTo(1, animDuration / 2, Easing.Out);
|
2017-09-26 16:13:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateCurrentState(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Idle:
|
2018-01-22 11:36:38 +00:00
|
|
|
|
this.Delay(HitObject.TimePreempt).FadeOut();
|
2017-09-26 16:13:34 +00:00
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Miss:
|
2018-01-22 11:36:38 +00:00
|
|
|
|
this.FadeOut(animDuration);
|
2017-09-26 16:13:34 +00:00
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Hit:
|
2018-01-22 11:36:38 +00:00
|
|
|
|
this.FadeOut(animDuration, Easing.OutQuint)
|
|
|
|
|
.ScaleTo(Scale * 1.5f, animDuration, Easing.OutQuint);
|
2017-09-26 16:13:34 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-18 12:06:47 +00:00
|
|
|
|
|
2018-01-23 10:31:37 +00:00
|
|
|
|
public void UpdateSnakingPosition(Vector2 start, Vector2 end)
|
|
|
|
|
{
|
2018-01-24 21:41:51 +00:00
|
|
|
|
Position = isRepeatAtEnd ? end : start;
|
2018-01-23 10:31:37 +00:00
|
|
|
|
var curve = drawableSlider.CurrentCurve;
|
|
|
|
|
if (curve.Count < 3 || curve.All(p => p == Position))
|
|
|
|
|
return;
|
2018-01-24 21:41:51 +00:00
|
|
|
|
var referencePoint = curve[isRepeatAtEnd ? curve.IndexOf(Position, curve.Count - 2) - 1 : curve[0] == curve[1] ? 2 : 1];
|
2018-01-23 10:31:37 +00:00
|
|
|
|
Rotation = MathHelper.RadiansToDegrees((float)Math.Atan2(referencePoint.Y - Position.Y, referencePoint.X - Position.X));
|
|
|
|
|
}
|
2017-09-26 16:13:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|