2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-09-11 17:12:43 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-04-02 13:51:28 +08:00
|
|
|
using osu.Framework.Graphics.Effects;
|
2020-01-09 12:43:44 +08:00
|
|
|
using osu.Framework.Utils;
|
2018-06-07 13:27:59 +08:00
|
|
|
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
2018-11-20 15:51:59 +08:00
|
|
|
using osuTK;
|
2019-09-11 17:12:43 +08:00
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.UI
|
|
|
|
{
|
|
|
|
internal class HitExplosion : CompositeDrawable
|
|
|
|
{
|
2018-06-12 11:53:53 +08:00
|
|
|
public override bool RemoveWhenNotAlive => true;
|
|
|
|
|
2019-09-11 17:12:43 +08:00
|
|
|
private readonly CircularContainer largeFaint;
|
|
|
|
private readonly CircularContainer mainGlow1;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-09-11 17:12:43 +08:00
|
|
|
public HitExplosion(Color4 objectColour, bool isSmall = false)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2018-06-07 13:27:59 +08:00
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
Height = NotePiece.NOTE_HEIGHT;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-06-07 13:27:59 +08:00
|
|
|
// scale roughly in-line with visual appearance of notes
|
2019-09-11 17:12:43 +08:00
|
|
|
Scale = new Vector2(1f, 0.6f);
|
|
|
|
|
|
|
|
if (isSmall)
|
|
|
|
Scale *= 0.5f;
|
|
|
|
|
|
|
|
const float angle_variangle = 15; // should be less than 45
|
|
|
|
|
|
|
|
const float roundness = 80;
|
|
|
|
|
|
|
|
const float initial_height = 10;
|
|
|
|
|
|
|
|
var colour = Interpolation.ValueAt(0.4f, objectColour, Color4.White, 0, 1);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-09-11 17:12:43 +08:00
|
|
|
InternalChildren = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-09-11 17:12:43 +08:00
|
|
|
largeFaint = new CircularContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-09-11 17:12:43 +08: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.
|
|
|
|
Size = new Vector2(0.8f),
|
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
Colour = Interpolation.ValueAt(0.1f, objectColour, Color4.White, 0, 1).Opacity(0.3f),
|
|
|
|
Roundness = 160,
|
|
|
|
Radius = 200,
|
|
|
|
},
|
2018-04-13 17:19:50 +08:00
|
|
|
},
|
2019-09-11 17:12:43 +08:00
|
|
|
mainGlow1 = new CircularContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-09-11 17:12:43 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2018-04-13 17:19:50 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-09-11 17:12:43 +08:00
|
|
|
Masking = true,
|
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
Colour = Interpolation.ValueAt(0.6f, objectColour, Color4.White, 0, 1),
|
|
|
|
Roundness = 20,
|
|
|
|
Radius = 50,
|
|
|
|
},
|
|
|
|
},
|
2019-09-12 13:09:21 +08:00
|
|
|
new CircularContainer
|
2019-09-11 17:12:43 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
|
|
|
Size = new Vector2(0.01f, initial_height),
|
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
Rotation = RNG.NextSingle(-angle_variangle, angle_variangle),
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
Colour = colour,
|
|
|
|
Roundness = roundness,
|
|
|
|
Radius = 40,
|
|
|
|
},
|
|
|
|
},
|
2019-09-12 13:09:21 +08:00
|
|
|
new CircularContainer
|
2019-09-11 17:12:43 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true,
|
|
|
|
Size = new Vector2(0.01f, initial_height),
|
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
Rotation = RNG.NextSingle(-angle_variangle, angle_variangle),
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
Colour = colour,
|
|
|
|
Roundness = roundness,
|
|
|
|
Radius = 40,
|
|
|
|
},
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
2019-09-11 17:12:43 +08:00
|
|
|
const double duration = 200;
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
base.LoadComplete();
|
|
|
|
|
2019-09-11 17:12:43 +08:00
|
|
|
largeFaint
|
|
|
|
.ResizeTo(largeFaint.Size * new Vector2(5, 1), duration, Easing.OutQuint)
|
|
|
|
.FadeOut(duration * 2);
|
|
|
|
|
|
|
|
mainGlow1.ScaleTo(1.4f, duration, Easing.OutQuint);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-09-11 17:12:43 +08:00
|
|
|
this.FadeOut(duration, Easing.Out);
|
2018-04-13 17:19:50 +08:00
|
|
|
Expire(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|