2021-07-25 17:00:37 +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.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Skinning.Legacy
|
|
|
|
{
|
2021-08-07 16:19:29 +00:00
|
|
|
public class LegacyHitExplosion : CompositeDrawable, IHitExplosion
|
2021-07-25 17:00:37 +00:00
|
|
|
{
|
|
|
|
[Resolved]
|
|
|
|
private Catcher catcher { get; set; }
|
|
|
|
|
|
|
|
private const float catch_margin = (1 - Catcher.ALLOWED_CATCH_RANGE) / 2;
|
|
|
|
|
|
|
|
private readonly Sprite explosion1;
|
|
|
|
private readonly Sprite explosion2;
|
|
|
|
|
|
|
|
public LegacyHitExplosion()
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomCentre;
|
|
|
|
Origin = Anchor.BottomCentre;
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
2021-08-12 20:33:09 +00:00
|
|
|
Scale = new Vector2(0.5f);
|
2021-07-25 17:00:37 +00:00
|
|
|
|
|
|
|
InternalChildren = new[]
|
|
|
|
{
|
|
|
|
explosion1 = new Sprite
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
Origin = Anchor.CentreLeft,
|
2021-08-11 20:36:27 +00:00
|
|
|
Alpha = 0,
|
2021-07-25 17:00:37 +00:00
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
Rotation = -90
|
|
|
|
},
|
|
|
|
explosion2 = new Sprite
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
Origin = Anchor.CentreLeft,
|
2021-08-11 20:36:27 +00:00
|
|
|
Alpha = 0,
|
2021-07-25 17:00:37 +00:00
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
Rotation = -90
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(SkinManager skins)
|
|
|
|
{
|
|
|
|
var defaultLegacySkin = skins.DefaultLegacySkin;
|
|
|
|
|
2021-08-12 19:13:45 +00:00
|
|
|
// sprite names intentionally swapped to match stable member naming / ease of cross-referencing
|
2021-07-25 17:00:37 +00:00
|
|
|
explosion1.Texture = defaultLegacySkin.GetTexture("scoreboard-explosion-2");
|
|
|
|
explosion2.Texture = defaultLegacySkin.GetTexture("scoreboard-explosion-1");
|
|
|
|
}
|
|
|
|
|
2021-08-07 16:19:29 +00:00
|
|
|
public void Animate(HitExplosionEntry entry)
|
2021-07-25 17:00:37 +00:00
|
|
|
{
|
|
|
|
Colour = entry.ObjectColour;
|
|
|
|
|
|
|
|
using (BeginAbsoluteSequence(entry.LifetimeStart))
|
|
|
|
{
|
|
|
|
float halfCatchWidth = catcher.CatchWidth / 2;
|
|
|
|
float explosionOffset = Math.Clamp(entry.Position, -halfCatchWidth + catch_margin * 3, halfCatchWidth - catch_margin * 3);
|
|
|
|
|
|
|
|
if (!(entry.HitObject is Droplet))
|
|
|
|
{
|
|
|
|
float scale = Math.Clamp(entry.JudgementResult.ComboAtJudgement / 200f, 0.35f, 1.125f);
|
|
|
|
|
|
|
|
explosion1.Scale = new Vector2(1, 0.9f);
|
|
|
|
explosion1.Position = new Vector2(explosionOffset, 0);
|
|
|
|
|
2021-08-07 16:19:29 +00:00
|
|
|
explosion1.FadeOutFromOne(300);
|
2021-08-12 20:33:09 +00:00
|
|
|
explosion1.ScaleTo(new Vector2(16 * scale, 1.1f), 160, Easing.Out);
|
2021-07-25 17:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
explosion2.Scale = new Vector2(0.9f, 1);
|
|
|
|
explosion2.Position = new Vector2(explosionOffset, 0);
|
|
|
|
|
2021-08-07 16:19:29 +00:00
|
|
|
explosion2.FadeOutFromOne(700);
|
2021-07-25 17:00:37 +00:00
|
|
|
explosion2.ScaleTo(new Vector2(0.9f, 1.3f), 500, Easing.Out);
|
2021-08-07 16:19:29 +00:00
|
|
|
|
|
|
|
this.Delay(700).FadeOutFromOne();
|
2021-07-25 17:00:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|