2020-04-01 19:00:52 +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.
|
|
|
|
|
2020-04-02 13:24:09 +08:00
|
|
|
using System;
|
2020-04-01 19:00:52 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
2020-04-02 13:24:09 +08:00
|
|
|
using osu.Framework.Graphics.Animations;
|
2020-04-01 19:00:52 +08:00
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
2020-04-02 13:24:09 +08:00
|
|
|
using osu.Game.Skinning;
|
2020-04-02 13:29:16 +08:00
|
|
|
using osuTK;
|
2020-04-01 19:00:52 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Skinning
|
|
|
|
{
|
2020-04-02 13:29:16 +08:00
|
|
|
public class LegacyHitExplosion : LegacyManiaColumnElement
|
2020-04-01 19:00:52 +08:00
|
|
|
{
|
|
|
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
|
|
|
|
|
|
|
private Drawable explosion;
|
|
|
|
|
2020-04-02 13:24:09 +08:00
|
|
|
public LegacyHitExplosion()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
}
|
|
|
|
|
2020-04-01 19:00:52 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2020-04-02 13:24:09 +08:00
|
|
|
private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
|
2020-04-01 19:00:52 +08:00
|
|
|
{
|
2020-04-02 13:24:09 +08:00
|
|
|
string imageName = GetManiaSkinConfig<string>(skin, LegacyManiaSkinConfigurationLookups.ExplosionImage)?.Value
|
|
|
|
?? "lightingN";
|
|
|
|
|
2020-04-02 13:29:16 +08:00
|
|
|
float explosionScale = GetManiaSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.ExplosionScale)?.Value
|
|
|
|
?? 1;
|
|
|
|
|
2020-04-02 14:27:31 +08:00
|
|
|
explosion = skin.GetAnimation(imageName, true, false, startAtCurrentTime: true).With(d =>
|
2020-04-01 19:00:52 +08:00
|
|
|
{
|
2020-04-02 13:24:09 +08:00
|
|
|
if (d == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
d.Origin = Anchor.Centre;
|
|
|
|
d.Blending = BlendingParameters.Additive;
|
2020-04-02 13:29:16 +08:00
|
|
|
d.Scale = new Vector2(explosionScale);
|
2020-04-02 13:24:09 +08:00
|
|
|
|
|
|
|
if (!(d is TextureAnimation texAnimation))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (texAnimation.FrameCount > 0)
|
|
|
|
texAnimation.DefaultFrameLength = Math.Max(texAnimation.DefaultFrameLength, 170.0 / texAnimation.FrameCount);
|
|
|
|
});
|
2020-04-01 19:00:52 +08:00
|
|
|
|
2020-04-02 14:27:31 +08:00
|
|
|
if (explosion != null)
|
|
|
|
InternalChild = explosion;
|
|
|
|
|
2020-04-01 19:00:52 +08:00
|
|
|
direction.BindTo(scrollingInfo.Direction);
|
|
|
|
direction.BindValueChanged(onDirectionChanged, true);
|
|
|
|
}
|
|
|
|
|
2020-04-02 13:24:09 +08:00
|
|
|
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
|
2020-04-01 19:00:52 +08:00
|
|
|
{
|
2020-04-02 13:24:09 +08:00
|
|
|
if (explosion != null)
|
|
|
|
explosion.Anchor = direction.NewValue == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre;
|
2020-04-01 19:00:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2020-04-02 13:24:09 +08:00
|
|
|
explosion?.FadeInFromZero(80)
|
|
|
|
.Then().FadeOut(120);
|
2020-04-01 19:00:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|