2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-09-27 00:13:34 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System;
|
2018-02-06 17:14:08 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-09-27 00:13:34 +08: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-31 04:23:18 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2017-09-27 00:13:34 +08:00
|
|
|
|
|
2017-09-27 00:21:39 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
2017-09-27 00:13:34 +08:00
|
|
|
|
{
|
2018-01-18 20:06:47 +08:00
|
|
|
|
public class DrawableRepeatPoint : DrawableOsuHitObject, ITrackSnaking
|
2017-09-27 00:13:34 +08:00
|
|
|
|
{
|
2017-09-27 23:28:44 +08:00
|
|
|
|
private readonly RepeatPoint repeatPoint;
|
2017-09-27 00:13:34 +08:00
|
|
|
|
private readonly DrawableSlider drawableSlider;
|
2018-01-25 05:41:51 +08:00
|
|
|
|
|
2018-01-22 19:36:38 +08:00
|
|
|
|
private double animDuration;
|
2017-09-27 00:13:34 +08:00
|
|
|
|
|
2017-11-03 14:30:46 +08:00
|
|
|
|
public DrawableRepeatPoint(RepeatPoint repeatPoint, DrawableSlider drawableSlider)
|
|
|
|
|
: base(repeatPoint)
|
2017-09-27 00:13:34 +08:00
|
|
|
|
{
|
2017-09-27 23:28:44 +08:00
|
|
|
|
this.repeatPoint = repeatPoint;
|
2017-09-27 00:13:34 +08:00
|
|
|
|
this.drawableSlider = drawableSlider;
|
|
|
|
|
|
2018-01-23 18:31:37 +08:00
|
|
|
|
Size = new Vector2(45 * repeatPoint.Scale);
|
2017-12-30 16:05:40 +08:00
|
|
|
|
|
2017-09-27 00:13:34 +08:00
|
|
|
|
Blending = BlendingMode.Additive;
|
|
|
|
|
Origin = Anchor.Centre;
|
2018-01-25 05:34:52 +08:00
|
|
|
|
|
2017-09-27 00:13:34 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new SpriteIcon
|
|
|
|
|
{
|
2017-12-30 16:05:40 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2018-01-23 18:31:37 +08:00
|
|
|
|
Icon = FontAwesome.fa_chevron_right
|
2017-09-27 00:13:34 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
|
|
|
|
{
|
2017-09-27 23:28:44 +08:00
|
|
|
|
if (repeatPoint.StartTime <= Time.Current)
|
2017-09-27 00:13:34 +08:00
|
|
|
|
AddJudgement(new OsuJudgement { Result = drawableSlider.Tracking ? HitResult.Great : HitResult.Miss });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdatePreemptState()
|
|
|
|
|
{
|
2018-01-23 16:04:45 +08:00
|
|
|
|
animDuration = Math.Min(150, repeatPoint.SpanDuration / 2);
|
2017-09-27 00:13:34 +08:00
|
|
|
|
|
2018-02-06 17:10:15 +08:00
|
|
|
|
this.Animate(
|
|
|
|
|
d => d.FadeIn(animDuration),
|
|
|
|
|
d => d.ScaleTo(0.5f).ScaleTo(1f, animDuration * 4, Easing.OutElasticHalf)
|
|
|
|
|
);
|
2017-09-27 00:13:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateCurrentState(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Idle:
|
2018-01-22 19:36:38 +08:00
|
|
|
|
this.Delay(HitObject.TimePreempt).FadeOut();
|
2017-09-27 00:13:34 +08:00
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Miss:
|
2018-01-22 19:36:38 +08:00
|
|
|
|
this.FadeOut(animDuration);
|
2017-09-27 00:13:34 +08:00
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Hit:
|
2018-01-22 19:36:38 +08:00
|
|
|
|
this.FadeOut(animDuration, Easing.OutQuint)
|
2018-02-06 16:46:56 +08:00
|
|
|
|
.ScaleTo(Scale * 1.5f, animDuration, Easing.Out);
|
2017-09-27 00:13:34 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-18 20:06:47 +08:00
|
|
|
|
|
2018-01-23 18:31:37 +08:00
|
|
|
|
public void UpdateSnakingPosition(Vector2 start, Vector2 end)
|
|
|
|
|
{
|
2018-02-06 17:14:08 +08:00
|
|
|
|
bool isRepeatAtEnd = repeatPoint.RepeatIndex % 2 == 0;
|
|
|
|
|
List<Vector2> curve = drawableSlider.Body.CurrentCurve;
|
2018-02-06 16:46:45 +08:00
|
|
|
|
|
2018-02-23 19:51:26 +08:00
|
|
|
|
Position = isRepeatAtEnd ? end : start;
|
2018-02-06 16:46:45 +08:00
|
|
|
|
|
|
|
|
|
if (curve.Count < 2)
|
2018-01-23 18:31:37 +08:00
|
|
|
|
return;
|
2018-02-06 16:46:45 +08:00
|
|
|
|
|
|
|
|
|
int searchStart = isRepeatAtEnd ? curve.Count - 1 : 0;
|
|
|
|
|
int direction = isRepeatAtEnd ? -1 : 1;
|
|
|
|
|
|
|
|
|
|
// find the next vector2 in the curve which is not equal to our current position to infer a rotation.
|
|
|
|
|
for (int i = searchStart; i >= 0 && i < curve.Count; i += direction)
|
2018-02-04 13:56:40 +08:00
|
|
|
|
{
|
2018-02-23 19:51:26 +08:00
|
|
|
|
if (curve[i] == Position)
|
2018-02-06 16:46:45 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
2018-02-23 19:51:26 +08:00
|
|
|
|
Rotation = MathHelper.RadiansToDegrees((float)Math.Atan2(curve[i].Y - Position.Y, curve[i].X - Position.X));
|
2018-02-06 16:46:45 +08:00
|
|
|
|
break;
|
2018-02-04 13:56:40 +08:00
|
|
|
|
}
|
2018-01-23 18:31:37 +08:00
|
|
|
|
}
|
2017-09-27 00:13:34 +08:00
|
|
|
|
}
|
|
|
|
|
}
|