2020-11-17 14:44:15 +08:00
|
|
|
// 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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-11-18 14:38:26 +08:00
|
|
|
using System;
|
2020-11-17 14:44:15 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Animations;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-11-18 16:15:45 +08:00
|
|
|
using osu.Framework.Utils;
|
2020-11-17 14:44:15 +08:00
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
|
|
|
namespace osu.Game.Skinning
|
|
|
|
{
|
2020-11-18 14:38:26 +08:00
|
|
|
public class LegacyJudgementPieceOld : CompositeDrawable, IAnimatableJudgement
|
2020-11-17 14:44:15 +08:00
|
|
|
{
|
|
|
|
private readonly HitResult result;
|
|
|
|
|
2020-11-18 14:38:26 +08:00
|
|
|
private readonly float finalScale;
|
2020-11-17 22:55:21 +08:00
|
|
|
|
2020-11-18 14:38:26 +08:00
|
|
|
public LegacyJudgementPieceOld(HitResult result, Func<Drawable> createMainDrawable, float finalScale = 1f)
|
2020-11-17 14:44:15 +08:00
|
|
|
{
|
|
|
|
this.result = result;
|
2020-11-18 14:38:26 +08:00
|
|
|
this.finalScale = finalScale;
|
2020-11-17 14:44:15 +08:00
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
2020-11-18 14:38:26 +08:00
|
|
|
InternalChild = createMainDrawable();
|
2020-11-17 14:44:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public virtual void PlayAnimation()
|
|
|
|
{
|
|
|
|
var animation = InternalChild as IFramedAnimation;
|
|
|
|
|
|
|
|
animation?.GotoFrame(0);
|
|
|
|
|
2020-11-18 16:15:45 +08:00
|
|
|
const double fade_in_length = 120;
|
|
|
|
const double fade_out_delay = 500;
|
|
|
|
const double fade_out_length = 600;
|
|
|
|
|
|
|
|
this.FadeInFromZero(fade_in_length);
|
|
|
|
this.Delay(fade_out_delay).FadeOut(fade_out_length);
|
2020-11-17 14:44:15 +08:00
|
|
|
|
|
|
|
// legacy judgements don't play any transforms if they are an animation.
|
|
|
|
if (animation?.FrameCount > 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (result)
|
|
|
|
{
|
|
|
|
case HitResult.Miss:
|
|
|
|
this.ScaleTo(1.6f);
|
|
|
|
this.ScaleTo(1, 100, Easing.In);
|
|
|
|
|
2020-11-18 16:15:45 +08:00
|
|
|
float rotation = RNG.NextSingle(-8.6f, 8.6f);
|
2020-11-17 14:44:15 +08:00
|
|
|
|
2020-11-18 16:15:45 +08:00
|
|
|
this.RotateTo(0);
|
|
|
|
this.RotateTo(rotation, fade_in_length)
|
|
|
|
.Then().RotateTo(rotation * 2, fade_out_delay + fade_out_length - fade_in_length, Easing.In);
|
2020-11-17 14:44:15 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2020-11-18 14:38:26 +08:00
|
|
|
|
|
|
|
this.ScaleTo(0.6f).Then()
|
2020-11-18 16:15:45 +08:00
|
|
|
.ScaleTo(1.1f, fade_in_length * 0.8f).Then()
|
2020-11-18 14:38:26 +08:00
|
|
|
// this is actually correct to match stable; there were overlapping transforms.
|
2020-11-18 16:15:45 +08:00
|
|
|
.ScaleTo(0.9f).Delay(fade_in_length * 0.2f)
|
|
|
|
.ScaleTo(1.1f).ScaleTo(0.9f, fade_in_length * 0.2f).Then()
|
|
|
|
.ScaleTo(0.95f).ScaleTo(finalScale, fade_in_length * 0.2f);
|
2020-11-17 14:44:15 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-11-20 15:14:38 +08:00
|
|
|
|
|
|
|
public Drawable GetAboveHitObjectsProxiedContent() => CreateProxy();
|
2020-11-17 14:44:15 +08:00
|
|
|
}
|
|
|
|
}
|