2020-04-27 21:22:32 +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.
|
|
|
|
|
2021-03-14 22:51:38 +08:00
|
|
|
using JetBrains.Annotations;
|
2020-09-27 21:29:04 +08:00
|
|
|
using osu.Framework.Allocation;
|
2020-04-27 21:22:32 +08:00
|
|
|
using osu.Framework.Graphics;
|
2021-03-14 22:51:38 +08:00
|
|
|
using osu.Framework.Graphics.Animations;
|
2020-04-27 21:22:32 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-09-27 22:07:19 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2021-03-14 22:51:38 +08:00
|
|
|
using osu.Game.Rulesets.Taiko.UI;
|
2020-04-27 21:22:32 +08:00
|
|
|
|
2020-12-07 11:30:25 +08:00
|
|
|
namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
2020-04-27 21:22:32 +08:00
|
|
|
{
|
2021-03-16 03:38:11 +08:00
|
|
|
public class LegacyHitExplosion : CompositeDrawable, IAnimatableHitExplosion
|
2020-04-27 21:22:32 +08:00
|
|
|
{
|
2020-09-27 21:29:04 +08:00
|
|
|
private readonly Drawable sprite;
|
|
|
|
|
2021-03-14 22:51:38 +08:00
|
|
|
[CanBeNull]
|
|
|
|
private readonly Drawable strongSprite;
|
2020-09-27 22:07:19 +08:00
|
|
|
|
2020-09-27 21:29:04 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Creates a new legacy hit explosion.
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// Contrary to stable's, this implementation doesn't require a frame-perfect hit
|
|
|
|
/// for the strong sprite to be displayed.
|
|
|
|
/// </remarks>
|
|
|
|
/// <param name="sprite">The normal legacy explosion sprite.</param>
|
|
|
|
/// <param name="strongSprite">The strong legacy explosion sprite.</param>
|
2021-03-14 22:51:38 +08:00
|
|
|
public LegacyHitExplosion(Drawable sprite, [CanBeNull] Drawable strongSprite = null)
|
2020-04-27 21:22:32 +08:00
|
|
|
{
|
2020-09-27 21:29:04 +08:00
|
|
|
this.sprite = sprite;
|
|
|
|
this.strongSprite = strongSprite;
|
|
|
|
}
|
2020-04-27 21:22:32 +08:00
|
|
|
|
2020-09-27 21:29:04 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2021-03-14 22:51:38 +08:00
|
|
|
private void load()
|
2020-09-27 21:29:04 +08:00
|
|
|
{
|
2020-04-27 21:22:32 +08:00
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
2020-09-27 21:29:04 +08:00
|
|
|
|
2020-09-28 00:11:12 +08:00
|
|
|
AddInternal(sprite.With(s =>
|
|
|
|
{
|
|
|
|
s.Anchor = Anchor.Centre;
|
|
|
|
s.Origin = Anchor.Centre;
|
|
|
|
}));
|
2020-09-27 21:29:04 +08:00
|
|
|
|
|
|
|
if (strongSprite != null)
|
2020-09-28 00:11:12 +08:00
|
|
|
{
|
|
|
|
AddInternal(strongSprite.With(s =>
|
|
|
|
{
|
|
|
|
s.Alpha = 0;
|
|
|
|
s.Anchor = Anchor.Centre;
|
|
|
|
s.Origin = Anchor.Centre;
|
|
|
|
}));
|
|
|
|
}
|
2020-04-27 21:22:32 +08:00
|
|
|
}
|
|
|
|
|
2021-03-14 22:51:38 +08:00
|
|
|
public void Animate(DrawableHitObject drawableHitObject)
|
2020-04-27 21:22:32 +08:00
|
|
|
{
|
2020-04-29 16:53:25 +08:00
|
|
|
const double animation_time = 120;
|
|
|
|
|
2021-03-14 22:51:38 +08:00
|
|
|
(sprite as IFramedAnimation)?.GotoFrame(0);
|
|
|
|
(strongSprite as IFramedAnimation)?.GotoFrame(0);
|
|
|
|
|
2020-04-29 16:53:25 +08:00
|
|
|
this.FadeInFromZero(animation_time).Then().FadeOut(animation_time * 1.5);
|
|
|
|
|
|
|
|
this.ScaleTo(0.6f)
|
|
|
|
.Then().ScaleTo(1.1f, animation_time * 0.8)
|
|
|
|
.Then().ScaleTo(0.9f, animation_time * 0.4)
|
|
|
|
.Then().ScaleTo(1f, animation_time * 0.2);
|
2020-04-27 21:22:32 +08:00
|
|
|
}
|
2020-09-27 22:07:19 +08:00
|
|
|
|
2021-03-14 22:51:38 +08:00
|
|
|
public void AnimateSecondHit()
|
2020-09-27 22:07:19 +08:00
|
|
|
{
|
2021-03-14 22:51:38 +08:00
|
|
|
if (strongSprite == null)
|
|
|
|
return;
|
2020-09-27 22:07:19 +08:00
|
|
|
|
2021-03-14 22:51:38 +08:00
|
|
|
sprite.FadeOut(50, Easing.OutQuint);
|
|
|
|
strongSprite.FadeIn(50, Easing.OutQuint);
|
2020-09-27 22:07:19 +08:00
|
|
|
}
|
2020-04-27 21:22:32 +08:00
|
|
|
}
|
|
|
|
}
|