2017-02-14 17:55:54 +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-08-18 15:16:00 +08:00
|
|
|
|
using System.Linq;
|
2017-02-14 17:55:54 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-02-15 22:24:08 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
2017-02-14 17:55:54 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
2017-05-18 18:40:20 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Allocation;
|
2017-09-06 16:02:13 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Judgements;
|
2017-05-18 18:40:20 +08:00
|
|
|
|
using osu.Game.Screens.Ranking;
|
2017-02-14 17:55:54 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
2017-02-14 17:55:54 +08:00
|
|
|
|
{
|
|
|
|
|
public class DrawableSpinner : DrawableOsuHitObject
|
|
|
|
|
{
|
2017-12-28 04:23:56 +08:00
|
|
|
|
public readonly Spinner Spinner;
|
2017-02-14 17:55:54 +08:00
|
|
|
|
|
2017-12-27 00:25:18 +08:00
|
|
|
|
public readonly SpinnerDisc Disc;
|
|
|
|
|
public readonly SpinnerTicks Ticks;
|
2017-10-07 15:31:42 +08:00
|
|
|
|
private readonly SpinnerSpmCounter spmCounter;
|
2017-05-18 18:40:20 +08:00
|
|
|
|
|
|
|
|
|
private readonly Container mainContainer;
|
|
|
|
|
|
2017-12-27 00:25:18 +08:00
|
|
|
|
public readonly SpinnerBackground Background;
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly Container circleContainer;
|
2017-05-18 18:40:20 +08:00
|
|
|
|
private readonly CirclePiece circle;
|
2017-05-18 20:38:19 +08:00
|
|
|
|
private readonly GlowPiece glow;
|
2017-10-05 20:07:33 +08:00
|
|
|
|
|
2017-08-03 13:36:21 +08:00
|
|
|
|
private readonly SpriteIcon symbol;
|
2017-05-18 18:40:20 +08:00
|
|
|
|
|
2017-05-22 08:50:45 +08:00
|
|
|
|
private readonly Color4 baseColour = OsuColour.FromHex(@"002c3c");
|
|
|
|
|
private readonly Color4 fillColour = OsuColour.FromHex(@"005b7c");
|
|
|
|
|
|
2017-05-18 18:40:20 +08:00
|
|
|
|
private Color4 normalColour;
|
|
|
|
|
private Color4 completeColour;
|
2017-02-14 17:55:54 +08:00
|
|
|
|
|
|
|
|
|
public DrawableSpinner(Spinner s) : base(s)
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
Position = s.Position;
|
|
|
|
|
|
2017-05-18 18:40:20 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
2017-05-18 18:51:45 +08:00
|
|
|
|
|
2017-05-18 18:40:20 +08:00
|
|
|
|
// we are slightly bigger than our parent, to clip the top and bottom of the circle
|
2017-05-18 20:38:19 +08:00
|
|
|
|
Height = 1.3f;
|
2017-02-14 17:55:54 +08:00
|
|
|
|
|
2017-12-28 04:23:56 +08:00
|
|
|
|
Spinner = s;
|
2017-02-14 17:55:54 +08:00
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-02-15 22:24:08 +08:00
|
|
|
|
circleContainer = new Container
|
2017-02-14 17:55:54 +08:00
|
|
|
|
{
|
2017-02-15 22:24:08 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2017-02-14 17:55:54 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
2017-02-15 22:24:08 +08:00
|
|
|
|
Origin = Anchor.Centre,
|
2017-05-18 18:40:20 +08:00
|
|
|
|
Children = new Drawable[]
|
2017-02-15 22:24:08 +08:00
|
|
|
|
{
|
2017-05-18 20:38:19 +08:00
|
|
|
|
glow = new GlowPiece(),
|
2017-05-18 18:40:20 +08:00
|
|
|
|
circle = new CirclePiece
|
2017-02-15 22:24:08 +08:00
|
|
|
|
{
|
|
|
|
|
Position = Vector2.Zero,
|
|
|
|
|
Anchor = Anchor.Centre,
|
2017-05-18 18:40:20 +08:00
|
|
|
|
},
|
|
|
|
|
new RingPiece(),
|
2017-08-03 13:36:21 +08:00
|
|
|
|
symbol = new SpriteIcon
|
2017-05-18 18:40:20 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2017-08-03 13:36:21 +08:00
|
|
|
|
Size = new Vector2(48),
|
2017-05-18 18:40:20 +08:00
|
|
|
|
Icon = FontAwesome.fa_asterisk,
|
|
|
|
|
Shadow = false,
|
2017-05-18 20:38:19 +08:00
|
|
|
|
},
|
2017-02-15 22:24:08 +08:00
|
|
|
|
}
|
2017-05-18 18:40:20 +08:00
|
|
|
|
},
|
|
|
|
|
mainContainer = new AspectContainer
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-12-27 00:25:18 +08:00
|
|
|
|
Background = new SpinnerBackground
|
2017-05-18 18:40:20 +08:00
|
|
|
|
{
|
2017-05-18 20:38:19 +08:00
|
|
|
|
Alpha = 0.6f,
|
2017-05-18 18:40:20 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
},
|
2017-12-28 04:23:56 +08:00
|
|
|
|
Disc = new SpinnerDisc(Spinner)
|
2017-05-18 18:40:20 +08:00
|
|
|
|
{
|
|
|
|
|
Scale = Vector2.Zero,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
},
|
|
|
|
|
circleContainer.CreateProxy(),
|
2017-12-27 00:25:18 +08:00
|
|
|
|
Ticks = new SpinnerTicks
|
2017-05-18 18:40:20 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
2017-10-07 15:31:42 +08:00
|
|
|
|
spmCounter = new SpinnerSpmCounter
|
2017-10-05 19:55:20 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
2017-10-07 15:31:42 +08:00
|
|
|
|
Origin = Anchor.Centre,
|
2017-10-05 20:07:33 +08:00
|
|
|
|
Y = 120,
|
|
|
|
|
Alpha = 0
|
2017-10-07 15:31:42 +08:00
|
|
|
|
}
|
2017-02-14 17:55:54 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-28 04:23:56 +08:00
|
|
|
|
public float Progress => MathHelper.Clamp(Disc.RotationAbsolute / 360 / Spinner.SpinsRequired, 0, 1);
|
2017-05-18 18:40:20 +08:00
|
|
|
|
|
2017-09-06 16:02:13 +08:00
|
|
|
|
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
2017-02-14 17:55:54 +08:00
|
|
|
|
{
|
|
|
|
|
if (Time.Current < HitObject.StartTime) return;
|
|
|
|
|
|
2017-12-27 00:25:18 +08:00
|
|
|
|
if (Progress >= 1 && !Disc.Complete)
|
2017-05-18 18:40:20 +08:00
|
|
|
|
{
|
2017-12-27 00:25:18 +08:00
|
|
|
|
Disc.Complete = true;
|
2017-02-15 22:24:08 +08:00
|
|
|
|
|
2017-05-18 20:38:19 +08:00
|
|
|
|
const float duration = 200;
|
|
|
|
|
|
2017-12-27 00:25:18 +08:00
|
|
|
|
Disc.FadeAccent(completeColour, duration);
|
2017-05-18 20:38:19 +08:00
|
|
|
|
|
2017-12-27 00:25:18 +08:00
|
|
|
|
Background.FadeAccent(completeColour, duration);
|
|
|
|
|
Background.FadeOut(duration);
|
2017-05-18 20:38:19 +08:00
|
|
|
|
|
|
|
|
|
circle.FadeColour(completeColour, duration);
|
|
|
|
|
glow.FadeColour(completeColour, duration);
|
2017-05-18 18:40:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-28 04:23:56 +08:00
|
|
|
|
if (!userTriggered && Time.Current >= Spinner.EndTime)
|
2017-02-14 17:55:54 +08:00
|
|
|
|
{
|
|
|
|
|
if (Progress >= 1)
|
2017-09-06 16:02:13 +08:00
|
|
|
|
AddJudgement(new OsuJudgement { Result = HitResult.Great });
|
2017-02-14 17:55:54 +08:00
|
|
|
|
else if (Progress > .9)
|
2017-09-06 16:02:13 +08:00
|
|
|
|
AddJudgement(new OsuJudgement { Result = HitResult.Good });
|
2017-02-14 17:55:54 +08:00
|
|
|
|
else if (Progress > .75)
|
2017-09-06 16:02:13 +08:00
|
|
|
|
AddJudgement(new OsuJudgement { Result = HitResult.Meh });
|
2017-12-28 04:23:56 +08:00
|
|
|
|
else if (Time.Current >= Spinner.EndTime)
|
2017-09-06 16:02:13 +08:00
|
|
|
|
AddJudgement(new OsuJudgement { Result = HitResult.Miss });
|
2017-02-14 17:55:54 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 18:40:20 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
2017-05-22 08:50:45 +08:00
|
|
|
|
normalColour = baseColour;
|
2017-05-18 20:56:19 +08:00
|
|
|
|
|
2017-12-27 00:25:18 +08:00
|
|
|
|
Background.AccentColour = normalColour;
|
2017-05-18 20:38:19 +08:00
|
|
|
|
|
2017-05-21 16:21:49 +08:00
|
|
|
|
completeColour = colours.YellowLight.Opacity(0.75f);
|
2017-02-14 17:55:54 +08:00
|
|
|
|
|
2017-12-27 00:25:18 +08:00
|
|
|
|
Disc.AccentColour = fillColour;
|
2017-05-18 21:21:41 +08:00
|
|
|
|
circle.Colour = colours.BlueDark;
|
|
|
|
|
glow.Colour = colours.BlueDark;
|
2017-05-18 18:40:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-18 15:16:00 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
2017-12-27 00:25:18 +08:00
|
|
|
|
Disc.Tracking = OsuActionInputManager.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton);
|
|
|
|
|
if (!spmCounter.IsPresent && Disc.Tracking)
|
|
|
|
|
spmCounter.FadeIn(FadeIn);
|
2017-08-18 15:19:10 +08:00
|
|
|
|
|
2017-08-18 15:16:00 +08:00
|
|
|
|
base.Update();
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-18 18:40:20 +08:00
|
|
|
|
protected override void UpdateAfterChildren()
|
|
|
|
|
{
|
|
|
|
|
base.UpdateAfterChildren();
|
|
|
|
|
|
2017-12-27 00:25:18 +08:00
|
|
|
|
circle.Rotation = Disc.Rotation;
|
|
|
|
|
Ticks.Rotation = Disc.Rotation;
|
|
|
|
|
spmCounter.SetRotation(Disc.RotationAbsolute);
|
2017-05-18 18:40:20 +08:00
|
|
|
|
|
2017-12-28 04:23:56 +08:00
|
|
|
|
float relativeCircleScale = Spinner.Scale * circle.DrawHeight / mainContainer.DrawHeight;
|
2017-12-27 00:25:18 +08:00
|
|
|
|
Disc.ScaleTo(relativeCircleScale + (1 - relativeCircleScale) * Progress, 200, Easing.OutQuint);
|
2017-05-18 18:40:20 +08:00
|
|
|
|
|
2017-12-27 00:25:18 +08:00
|
|
|
|
symbol.RotateTo(Disc.Rotation / 2, 500, Easing.OutQuint);
|
2017-05-18 18:40:20 +08:00
|
|
|
|
}
|
2017-02-14 17:55:54 +08:00
|
|
|
|
|
|
|
|
|
protected override void UpdatePreemptState()
|
|
|
|
|
{
|
|
|
|
|
base.UpdatePreemptState();
|
|
|
|
|
|
2017-12-28 04:23:56 +08:00
|
|
|
|
circleContainer.ScaleTo(Spinner.Scale * 0.3f);
|
|
|
|
|
circleContainer.ScaleTo(Spinner.Scale, TIME_PREEMPT / 1.4f, Easing.OutQuint);
|
2017-02-22 17:08:31 +08:00
|
|
|
|
|
2017-12-27 00:25:18 +08:00
|
|
|
|
Disc.RotateTo(-720);
|
2017-05-18 18:40:20 +08:00
|
|
|
|
symbol.RotateTo(-720);
|
2017-02-22 17:08:31 +08:00
|
|
|
|
|
2017-07-17 22:05:24 +08:00
|
|
|
|
mainContainer
|
|
|
|
|
.ScaleTo(0)
|
2017-12-28 04:23:56 +08:00
|
|
|
|
.ScaleTo(Spinner.Scale * circle.DrawHeight / DrawHeight * 1.4f, TIME_PREEMPT - 150, Easing.OutQuint)
|
2017-07-17 22:05:24 +08:00
|
|
|
|
.Then()
|
2017-07-23 02:50:25 +08:00
|
|
|
|
.ScaleTo(1, 500, Easing.OutQuint);
|
2017-02-14 17:55:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-27 16:37:38 +08:00
|
|
|
|
protected override void UpdateCurrentState(ArmedState state)
|
2017-02-14 17:55:54 +08:00
|
|
|
|
{
|
2017-12-28 04:23:56 +08:00
|
|
|
|
var sequence = this.Delay(Spinner.Duration).FadeOut(160);
|
2017-02-15 22:24:08 +08:00
|
|
|
|
|
2017-02-14 17:55:54 +08:00
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Hit:
|
2017-07-23 02:50:25 +08:00
|
|
|
|
sequence.ScaleTo(Scale * 1.2f, 320, Easing.Out);
|
2017-02-14 17:55:54 +08:00
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Miss:
|
2017-07-23 02:50:25 +08:00
|
|
|
|
sequence.ScaleTo(Scale * 0.8f, 320, Easing.In);
|
2017-02-14 17:55:54 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2017-07-17 22:05:24 +08:00
|
|
|
|
|
2017-07-17 23:16:15 +08:00
|
|
|
|
Expire();
|
2017-02-14 17:55:54 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|