2020-04-27 13:22:32 +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-09-27 14:07:19 +00:00
|
|
|
using System.Linq;
|
2020-09-27 13:29:04 +00:00
|
|
|
using osu.Framework.Allocation;
|
2020-04-27 13:22:32 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-09-27 14:07:19 +00:00
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
2020-04-27 13:22:32 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Skinning
|
|
|
|
{
|
|
|
|
public class LegacyHitExplosion : CompositeDrawable
|
|
|
|
{
|
2020-09-27 13:29:04 +00:00
|
|
|
private readonly Drawable sprite;
|
|
|
|
private readonly Drawable strongSprite;
|
|
|
|
|
2020-09-27 14:07:19 +00:00
|
|
|
private DrawableHit hit;
|
|
|
|
private DrawableStrongNestedHit nestedStrongHit;
|
|
|
|
|
2020-09-27 13:29:04 +00: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>
|
|
|
|
public LegacyHitExplosion(Drawable sprite, Drawable strongSprite = null)
|
2020-04-27 13:22:32 +00:00
|
|
|
{
|
2020-09-27 13:29:04 +00:00
|
|
|
this.sprite = sprite;
|
|
|
|
this.strongSprite = strongSprite;
|
|
|
|
}
|
2020-04-27 13:22:32 +00:00
|
|
|
|
2020-09-27 13:29:04 +00:00
|
|
|
[BackgroundDependencyLoader]
|
2020-09-27 14:07:19 +00:00
|
|
|
private void load(DrawableHitObject judgedObject)
|
2020-09-27 13:29:04 +00:00
|
|
|
{
|
2020-04-27 13:22:32 +00:00
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
2020-09-27 13:29:04 +00:00
|
|
|
|
|
|
|
AddInternal(sprite);
|
|
|
|
|
|
|
|
if (strongSprite != null)
|
|
|
|
AddInternal(strongSprite.With(s => s.Alpha = 0));
|
2020-09-27 14:07:19 +00:00
|
|
|
|
|
|
|
if (judgedObject is DrawableHit h)
|
|
|
|
{
|
|
|
|
hit = h;
|
|
|
|
nestedStrongHit = hit.NestedHitObjects.SingleOrDefault() as DrawableStrongNestedHit;
|
|
|
|
}
|
2020-04-27 13:22:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2020-04-29 08:53:25 +00:00
|
|
|
const double animation_time = 120;
|
|
|
|
|
|
|
|
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-30 07:18:15 +00:00
|
|
|
|
|
|
|
Expire(true);
|
2020-04-27 13:22:32 +00:00
|
|
|
}
|
2020-09-27 14:07:19 +00:00
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
if (shouldSwitchToStrongSprite() && strongSprite != null)
|
|
|
|
{
|
|
|
|
sprite.FadeOut(50, Easing.OutQuint);
|
|
|
|
strongSprite.FadeIn(50, Easing.OutQuint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private bool shouldSwitchToStrongSprite()
|
|
|
|
{
|
|
|
|
if (hit == null || nestedStrongHit == null)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return hit.Result.Type == nestedStrongHit.Result.Type;
|
|
|
|
}
|
2020-04-27 13:22:32 +00:00
|
|
|
}
|
|
|
|
}
|