Move all extended animation logic out of DrawableJudgement

This commit is contained in:
Dean Herbert
2020-11-17 14:59:34 +09:00
parent 82c3925a37
commit f465dd5a5e
5 changed files with 146 additions and 42 deletions

View File

@ -0,0 +1,65 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Scoring;
using osuTK;
namespace osu.Game.Rulesets.Judgements
{
public class DefaultJudgementPiece : CompositeDrawable, IAnimatableJudgement
{
protected SpriteText JudgementText { get; }
[Resolved]
private OsuColour colours { get; set; }
public DefaultJudgementPiece()
{
Origin = Anchor.Centre;
AutoSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
JudgementText = new OsuSpriteText
{
Font = OsuFont.Numeric.With(size: 20),
Scale = new Vector2(0.85f, 1),
}
};
}
public virtual void PlayAnimation(HitResult result)
{
JudgementText.Text = result.GetDescription().ToUpperInvariant();
JudgementText.Colour = colours.ForHitResult(result);
this.RotateTo(0);
this.MoveTo(Vector2.Zero);
switch (result)
{
case HitResult.Miss:
this.ScaleTo(1.6f);
this.ScaleTo(1, 100, Easing.In);
this.MoveToOffset(new Vector2(0, 100), 800, Easing.InQuint);
this.RotateTo(40, 800, Easing.InQuint);
break;
default:
this.ScaleTo(0.9f);
this.ScaleTo(1, 500, Easing.OutElastic);
break;
}
}
}
}