2019-01-24 08:43:03 +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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2020-04-01 10:19:32 +00:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
2019-09-11 09:12:43 +00:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-09-11 05:35:18 +00:00
|
|
|
using osu.Framework.Graphics;
|
2017-09-11 04:44:39 +00:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-04-02 05:51:28 +00:00
|
|
|
using osu.Framework.Graphics.Effects;
|
2020-01-09 04:43:44 +00:00
|
|
|
using osu.Framework.Utils;
|
2020-07-29 07:14:19 +00:00
|
|
|
using osu.Game.Rulesets.Judgements;
|
2020-12-07 03:32:52 +00:00
|
|
|
using osu.Game.Rulesets.Mania.Skinning.Default;
|
2020-04-01 10:19:32 +00:00
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
2018-11-20 07:51:59 +00:00
|
|
|
using osuTK;
|
2019-09-11 09:12:43 +00:00
|
|
|
using osuTK.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2017-09-11 04:44:39 +00:00
|
|
|
namespace osu.Game.Rulesets.Mania.UI
|
|
|
|
{
|
2020-07-29 06:36:42 +00:00
|
|
|
public partial class DefaultHitExplosion : CompositeDrawable, IHitExplosion
|
2017-09-11 04:44:39 +00:00
|
|
|
{
|
2020-07-29 06:52:25 +00:00
|
|
|
private const float default_large_faint_size = 0.8f;
|
|
|
|
|
2018-06-12 03:53:53 +00:00
|
|
|
public override bool RemoveWhenNotAlive => true;
|
|
|
|
|
2020-07-29 07:14:19 +00:00
|
|
|
[Resolved]
|
|
|
|
private Column column { get; set; }
|
|
|
|
|
2020-04-01 10:19:32 +00:00
|
|
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
|
|
|
|
2020-07-29 07:14:19 +00:00
|
|
|
private CircularContainer largeFaint;
|
|
|
|
private CircularContainer mainGlow1;
|
2022-10-05 11:02:02 +00:00
|
|
|
private CircularContainer mainGlow2;
|
|
|
|
private CircularContainer mainGlow3;
|
|
|
|
|
|
|
|
private Bindable<Color4> accentColour;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-07-29 07:14:19 +00:00
|
|
|
public DefaultHitExplosion()
|
2017-09-11 04:44:39 +00:00
|
|
|
{
|
2020-04-01 10:19:32 +00:00
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
2018-06-07 05:27:59 +00:00
|
|
|
RelativeSizeAxes = Axes.X;
|
2020-03-31 06:29:25 +00:00
|
|
|
Height = DefaultNotePiece.NOTE_HEIGHT;
|
2020-07-29 07:14:19 +00:00
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-07-29 07:14:19 +00:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(IScrollingInfo scrollingInfo)
|
|
|
|
{
|
2021-12-28 05:44:19 +00:00
|
|
|
const float angle_variance = 15; // should be less than 45
|
2019-09-11 09:12:43 +00:00
|
|
|
const float roundness = 80;
|
|
|
|
const float initial_height = 10;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
2017-09-11 04:44:39 +00:00
|
|
|
{
|
2019-09-11 09:12:43 +00:00
|
|
|
largeFaint = new CircularContainer
|
2017-09-11 04:44:39 +00:00
|
|
|
{
|
2019-09-11 09:12:43 +00:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
|
|
|
// we want our size to be very small so the glow dominates it.
|
2020-07-29 06:52:25 +00:00
|
|
|
Size = new Vector2(default_large_faint_size),
|
2019-09-11 09:12:43 +00:00
|
|
|
Blending = BlendingParameters.Additive,
|
2017-09-11 04:44:39 +00:00
|
|
|
},
|
2019-09-11 09:12:43 +00:00
|
|
|
mainGlow1 = new CircularContainer
|
2017-09-11 04:44:39 +00:00
|
|
|
{
|
2019-09-11 09:12:43 +00:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2017-09-11 04:44:39 +00:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-09-11 09:12:43 +00:00
|
|
|
Masking = true,
|
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
},
|
2022-10-05 11:02:02 +00:00
|
|
|
mainGlow2 = new CircularContainer
|
2019-09-11 09:12:43 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
|
|
|
Size = new Vector2(0.01f, initial_height),
|
|
|
|
Blending = BlendingParameters.Additive,
|
2021-12-28 05:44:19 +00:00
|
|
|
Rotation = RNG.NextSingle(-angle_variance, angle_variance),
|
2019-09-11 09:12:43 +00:00
|
|
|
},
|
2022-10-05 11:02:02 +00:00
|
|
|
mainGlow3 = new CircularContainer
|
2019-09-11 09:12:43 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
|
|
|
Size = new Vector2(0.01f, initial_height),
|
|
|
|
Blending = BlendingParameters.Additive,
|
2021-12-28 05:44:19 +00:00
|
|
|
Rotation = RNG.NextSingle(-angle_variance, angle_variance),
|
2017-09-11 04:44:39 +00:00
|
|
|
}
|
|
|
|
};
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-04-01 10:19:32 +00:00
|
|
|
direction.BindTo(scrollingInfo.Direction);
|
|
|
|
direction.BindValueChanged(onDirectionChanged, true);
|
2022-10-05 11:02:02 +00:00
|
|
|
|
|
|
|
accentColour = column.AccentColour.GetBoundCopy();
|
|
|
|
accentColour.BindValueChanged(colour =>
|
|
|
|
{
|
|
|
|
largeFaint.EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
Colour = Interpolation.ValueAt(0.1f, colour.NewValue, Color4.White, 0, 1).Opacity(0.3f),
|
|
|
|
Roundness = 160,
|
|
|
|
Radius = 200,
|
|
|
|
};
|
|
|
|
mainGlow1.EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
Colour = Interpolation.ValueAt(0.6f, colour.NewValue, Color4.White, 0, 1),
|
|
|
|
Roundness = 20,
|
|
|
|
Radius = 50,
|
|
|
|
};
|
|
|
|
mainGlow2.EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
Colour = Interpolation.ValueAt(0.4f, colour.NewValue, Color4.White, 0, 1),
|
|
|
|
Roundness = roundness,
|
|
|
|
Radius = 40,
|
|
|
|
};
|
|
|
|
mainGlow3.EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
Colour = Interpolation.ValueAt(0.4f, colour.NewValue, Color4.White, 0, 1),
|
|
|
|
Roundness = roundness,
|
|
|
|
Radius = 40,
|
|
|
|
};
|
|
|
|
}, true);
|
2020-04-01 10:19:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
|
|
|
|
{
|
|
|
|
if (direction.NewValue == ScrollingDirection.Up)
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre;
|
|
|
|
Y = DefaultNotePiece.NOTE_HEIGHT / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomCentre;
|
|
|
|
Y = -DefaultNotePiece.NOTE_HEIGHT / 2;
|
|
|
|
}
|
|
|
|
}
|
2020-07-29 06:36:42 +00:00
|
|
|
|
2020-07-29 07:14:19 +00:00
|
|
|
public void Animate(JudgementResult result)
|
2020-07-29 06:36:42 +00:00
|
|
|
{
|
2020-07-29 07:14:19 +00:00
|
|
|
// scale roughly in-line with visual appearance of notes
|
|
|
|
Vector2 scale = new Vector2(1, 0.6f);
|
|
|
|
|
|
|
|
this.ScaleTo(scale);
|
|
|
|
|
2020-07-29 06:36:42 +00:00
|
|
|
largeFaint
|
2020-07-29 06:52:25 +00:00
|
|
|
.ResizeTo(default_large_faint_size)
|
|
|
|
.Then()
|
|
|
|
.ResizeTo(default_large_faint_size * new Vector2(5, 1), PoolableHitExplosion.DURATION, Easing.OutQuint)
|
2020-07-29 06:36:42 +00:00
|
|
|
.FadeOut(PoolableHitExplosion.DURATION * 2);
|
|
|
|
|
2020-07-29 06:52:25 +00:00
|
|
|
mainGlow1
|
|
|
|
.ScaleTo(1)
|
|
|
|
.Then()
|
|
|
|
.ScaleTo(1.4f, PoolableHitExplosion.DURATION, Easing.OutQuint);
|
2020-07-29 06:36:42 +00:00
|
|
|
|
2020-07-29 06:52:25 +00:00
|
|
|
this.FadeOutFromOne(PoolableHitExplosion.DURATION, Easing.Out);
|
2020-07-29 06:36:42 +00:00
|
|
|
}
|
2017-09-11 04:44:39 +00:00
|
|
|
}
|
|
|
|
}
|