1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-05 13:42:59 +08:00

Redo the drawable structure of bubbledrawable to run and look better

This commit is contained in:
mk56-spn 2023-01-28 22:44:57 +01:00
parent 66da4c0288
commit 3bdf83bf44

View File

@ -5,6 +5,7 @@ using System;
using System.Linq; using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Performance; using osu.Framework.Graphics.Performance;
@ -93,7 +94,7 @@ namespace osu.Game.Rulesets.Osu.Mods
//Needs to be done explicitly to avoid being handled by DrawableHitCircle below //Needs to be done explicitly to avoid being handled by DrawableHitCircle below
case DrawableSliderHead: case DrawableSliderHead:
addBubbleContainer(hitObject.Position, drawableOsuObject); addBubbleContainer(hitObject.Position, drawableOsuObject);
break; return;
//Stack leniency causes placement issues if this isn't handled as such. //Stack leniency causes placement issues if this isn't handled as such.
case DrawableHitCircle hitCircle: case DrawableHitCircle hitCircle:
@ -188,7 +189,6 @@ namespace osu.Game.Rulesets.Osu.Mods
private partial class BubbleDrawable : CircularContainer private partial class BubbleDrawable : CircularContainer
{ {
private readonly Circle innerCircle;
private readonly Box colourBox; private readonly Box colourBox;
public BubbleDrawable() public BubbleDrawable()
@ -196,55 +196,55 @@ namespace osu.Game.Rulesets.Osu.Mods
Anchor = Anchor.Centre; Anchor = Anchor.Centre;
Origin = Anchor.Centre; Origin = Anchor.Centre;
Masking = true;
MaskingSmoothness = 2; MaskingSmoothness = 2;
BorderThickness = 0; BorderThickness = 0;
BorderColour = Colour4.Transparent; BorderColour = Colour4.White;
Masking = true;
EdgeEffect = new EdgeEffectParameters EdgeEffect = new EdgeEffectParameters
{ {
Type = EdgeEffectType.Shadow, Type = EdgeEffectType.Shadow,
Radius = 3, Radius = 3,
Colour = Colour4.Black.Opacity(0.05f) Colour = Colour4.Black.Opacity(0.05f)
}; };
Child = colourBox = new Box { RelativeSizeAxes = Axes.Both, };
Children = new Drawable[]
{
colourBox = new Box { RelativeSizeAxes = Axes.Both, },
innerCircle = new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.5f),
}
};
} }
public void Animate(BubbleLifeTimeEntry entry) public void Animate(BubbleLifeTimeEntry entry)
{ {
Size = entry.InitialSize; Size = entry.InitialSize;
BorderThickness = Width / 3.5f;
//We want to fade to a darker colour to avoid colours such as white hiding the "ripple" effect. //We want to fade to a darker colour to avoid colours such as white hiding the "ripple" effect.
var colourDarker = entry.Colour.Darken(0.1f); ColourInfo colourDarker = entry.Colour.Darken(0.1f);
// Main bubble scaling based on combo
this.ScaleTo(entry.MaxSize, getAnimationDuration() * 0.8f) this.ScaleTo(entry.MaxSize, getAnimationDuration() * 0.8f)
.Then() .Then()
// Pop at the end of the bubbles life time
.ScaleTo(entry.MaxSize * 1.5f, getAnimationDuration() * 0.2f, Easing.OutQuint) .ScaleTo(entry.MaxSize * 1.5f, getAnimationDuration() * 0.2f, Easing.OutQuint)
.FadeTo(0, getAnimationDuration() * 0.2f, Easing.OutQuint); .FadeTo(0, getAnimationDuration() * 0.2f, Easing.OutCirc);
innerCircle.ScaleTo(2f, getAnimationDuration() * 0.8f, Easing.OutQuint);
if (!entry.IsHit) if (!entry.IsHit)
{ {
colourBox.Colour = Colour4.Black; Colour = Colour4.Black;
innerCircle.Colour = Colour4.Black; BorderColour = Colour4.Black;
return; return;
} }
colourBox.FadeColour(colourDarker, getAnimationDuration() * 0.2f, Easing.OutQuint colourBox.FadeColour(colourDarker);
);
innerCircle.FadeColour(colourDarker); this.TransformTo(nameof(BorderColour), colourDarker, getAnimationDuration() * 0.3f, Easing.OutQuint);
// Ripple effect utilises the border to reduce drawable count
this.TransformTo(nameof(BorderThickness), 2f, getAnimationDuration() * 0.3f, Easing.OutQuint)
// Avoids transparency overlap issues during the bubble "pop"
.Then().Schedule(() =>
{
BorderThickness = 0;
BorderColour = Colour4.Transparent;
});
// The absolute length of the bubble's animation, can be used in fractions for animations of partial length // The absolute length of the bubble's animation, can be used in fractions for animations of partial length
double getAnimationDuration() => 1700 + Math.Pow(entry.FadeTime, 1.07f); double getAnimationDuration() => 1700 + Math.Pow(entry.FadeTime, 1.07f);