2020-11-17 06:44:15 +00: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.
|
|
|
|
|
2020-11-18 06:38:26 +00:00
|
|
|
using System;
|
2023-01-26 13:01:33 +00:00
|
|
|
using osu.Framework.Allocation;
|
2020-11-17 06:44:15 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Animations;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-11-18 08:15:45 +00:00
|
|
|
using osu.Framework.Utils;
|
2020-11-17 06:44:15 +00:00
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2023-01-25 17:34:00 +00:00
|
|
|
using osuTK;
|
|
|
|
|
2020-11-17 06:44:15 +00:00
|
|
|
namespace osu.Game.Skinning
|
|
|
|
{
|
2020-11-18 06:38:26 +00:00
|
|
|
public partial class LegacyJudgementPieceOld : CompositeDrawable, IAnimatableJudgement
|
2020-11-17 06:44:15 +00:00
|
|
|
{
|
|
|
|
private readonly HitResult result;
|
|
|
|
|
2020-11-18 06:38:26 +00:00
|
|
|
private readonly float finalScale;
|
2024-01-29 10:41:03 +00:00
|
|
|
private readonly bool forceTransforms;
|
2020-11-17 14:55:21 +00:00
|
|
|
|
2023-01-26 13:01:33 +00:00
|
|
|
[Resolved]
|
|
|
|
private ISkinSource skin { get; set; } = null!;
|
|
|
|
|
2024-01-29 10:41:03 +00:00
|
|
|
public LegacyJudgementPieceOld(HitResult result, Func<Drawable> createMainDrawable, float finalScale = 1f, bool forceTransforms = false)
|
2020-11-17 06:44:15 +00:00
|
|
|
{
|
|
|
|
this.result = result;
|
2020-11-18 06:38:26 +00:00
|
|
|
this.finalScale = finalScale;
|
2024-01-29 10:41:03 +00:00
|
|
|
this.forceTransforms = forceTransforms;
|
2020-11-17 06:44:15 +00:00
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
2020-11-18 06:38:26 +00:00
|
|
|
InternalChild = createMainDrawable();
|
2020-11-17 06:44:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public virtual void PlayAnimation()
|
|
|
|
{
|
|
|
|
var animation = InternalChild as IFramedAnimation;
|
|
|
|
|
|
|
|
animation?.GotoFrame(0);
|
|
|
|
|
2020-11-18 08:15:45 +00:00
|
|
|
const double fade_in_length = 120;
|
|
|
|
const double fade_out_delay = 500;
|
|
|
|
const double fade_out_length = 600;
|
|
|
|
|
|
|
|
this.FadeInFromZero(fade_in_length);
|
2024-01-30 21:15:35 +00:00
|
|
|
this.Delay(fade_out_delay).FadeOut(fade_out_length);
|
2020-11-17 06:44:15 +00:00
|
|
|
|
2024-01-29 10:41:03 +00:00
|
|
|
// legacy judgements don't play any transforms if they are an animation.... UNLESS they are the temporary displayed judgement from new piece.
|
|
|
|
if (animation?.FrameCount > 1 && !forceTransforms)
|
|
|
|
return;
|
|
|
|
|
2023-12-20 15:58:43 +00:00
|
|
|
if (result.IsMiss())
|
2023-12-20 11:23:19 +00:00
|
|
|
{
|
2023-12-25 08:17:23 +00:00
|
|
|
decimal? legacyVersion = skin.GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value;
|
|
|
|
|
|
|
|
// missed ticks / slider end don't get the normal animation.
|
2023-12-21 12:58:12 +00:00
|
|
|
if (isMissedTick())
|
2023-12-20 11:26:28 +00:00
|
|
|
{
|
2024-01-22 09:48:48 +00:00
|
|
|
this.ScaleTo(1.2f);
|
|
|
|
this.ScaleTo(1f, 100, Easing.In);
|
2023-12-20 11:26:28 +00:00
|
|
|
|
2024-01-31 08:41:26 +00:00
|
|
|
this.Delay(fade_out_delay / 2).FadeOut(fade_out_length);
|
2023-12-25 08:17:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.ScaleTo(1.6f);
|
|
|
|
this.ScaleTo(1, 100, Easing.In);
|
2020-11-18 06:38:26 +00:00
|
|
|
|
2023-12-23 05:03:45 +00:00
|
|
|
if (legacyVersion > 1.0m)
|
2023-12-20 11:26:28 +00:00
|
|
|
{
|
|
|
|
this.MoveTo(new Vector2(0, -5));
|
|
|
|
this.MoveToOffset(new Vector2(0, 80), fade_out_delay + fade_out_length, Easing.In);
|
|
|
|
}
|
2023-01-18 10:03:03 +00:00
|
|
|
|
2023-12-20 11:26:28 +00:00
|
|
|
float rotation = RNG.NextSingle(-8.6f, 8.6f);
|
|
|
|
|
|
|
|
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 06:44:15 +00:00
|
|
|
}
|
2023-12-20 15:58:43 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
this.ScaleTo(0.6f).Then()
|
|
|
|
.ScaleTo(1.1f, fade_in_length * 0.8f).Then() // t = 0.8
|
|
|
|
.Delay(fade_in_length * 0.2f) // t = 1.0
|
|
|
|
.ScaleTo(0.9f, fade_in_length * 0.2f).Then() // t = 1.2
|
2023-12-20 18:07:26 +00:00
|
|
|
|
2023-12-20 15:58:43 +00:00
|
|
|
// stable dictates scale of 0.9->1 over time 1.0 to 1.4, but we are already at 1.2.
|
|
|
|
// so we need to force the current value to be correct at 1.2 (0.95) then complete the
|
|
|
|
// second half of the transform.
|
|
|
|
.ScaleTo(0.95f).ScaleTo(finalScale, fade_in_length * 0.2f); // t = 1.4
|
|
|
|
}
|
2020-11-17 06:44:15 +00:00
|
|
|
}
|
2020-11-20 07:14:38 +00:00
|
|
|
|
2023-12-21 12:58:12 +00:00
|
|
|
private bool isMissedTick() => result.IsMiss() && result != HitResult.Miss;
|
|
|
|
|
2020-11-20 07:14:38 +00:00
|
|
|
public Drawable GetAboveHitObjectsProxiedContent() => CreateProxy();
|
2020-11-17 06:44:15 +00:00
|
|
|
}
|
|
|
|
}
|