mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 07:32:58 +08:00
Merge pull request #11023 from ekrctb/pool-catch-hit-explosion
Pool osu!catch hit explosion
This commit is contained in:
commit
6b79d96517
@ -9,6 +9,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Animations;
|
using osu.Framework.Graphics.Animations;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Pooling;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -107,6 +108,9 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
private float hyperDashTargetPosition;
|
private float hyperDashTargetPosition;
|
||||||
private Bindable<bool> hitLighting;
|
private Bindable<bool> hitLighting;
|
||||||
|
|
||||||
|
private DrawablePool<HitExplosion> hitExplosionPool;
|
||||||
|
private Container<HitExplosion> hitExplosionContainer;
|
||||||
|
|
||||||
public Catcher([NotNull] Container trailsTarget, BeatmapDifficulty difficulty = null)
|
public Catcher([NotNull] Container trailsTarget, BeatmapDifficulty difficulty = null)
|
||||||
{
|
{
|
||||||
this.trailsTarget = trailsTarget;
|
this.trailsTarget = trailsTarget;
|
||||||
@ -127,6 +131,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
|
hitExplosionPool = new DrawablePool<HitExplosion>(10),
|
||||||
caughtFruitContainer,
|
caughtFruitContainer,
|
||||||
catcherIdle = new CatcherSprite(CatcherAnimationState.Idle)
|
catcherIdle = new CatcherSprite(CatcherAnimationState.Idle)
|
||||||
{
|
{
|
||||||
@ -142,7 +147,12 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
}
|
},
|
||||||
|
hitExplosionContainer = new Container<HitExplosion>
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
trails = new CatcherTrailDisplay(this);
|
trails = new CatcherTrailDisplay(this);
|
||||||
@ -209,11 +219,11 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
if (hitLighting.Value)
|
if (hitLighting.Value)
|
||||||
{
|
{
|
||||||
AddInternal(new HitExplosion(fruit)
|
HitExplosion hitExplosion = hitExplosionPool.Get();
|
||||||
{
|
hitExplosion.X = fruit.X;
|
||||||
X = fruit.X,
|
hitExplosion.Scale = new Vector2(fruit.HitObject.Scale);
|
||||||
Scale = new Vector2(fruit.HitObject.Scale)
|
hitExplosion.ObjectColour = fruit.AccentColour.Value;
|
||||||
});
|
hitExplosionContainer.Add(hitExplosion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,35 +5,43 @@ using osu.Framework.Extensions.Color4Extensions;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Effects;
|
using osu.Framework.Graphics.Effects;
|
||||||
|
using osu.Framework.Graphics.Pooling;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.UI
|
namespace osu.Game.Rulesets.Catch.UI
|
||||||
{
|
{
|
||||||
public class HitExplosion : CompositeDrawable
|
public class HitExplosion : PoolableDrawable
|
||||||
{
|
{
|
||||||
private readonly CircularContainer largeFaint;
|
private Color4 objectColour;
|
||||||
|
|
||||||
public HitExplosion(DrawableCatchHitObject fruit)
|
public Color4 ObjectColour
|
||||||
|
{
|
||||||
|
get => objectColour;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (objectColour == value) return;
|
||||||
|
|
||||||
|
objectColour = value;
|
||||||
|
onColourChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly CircularContainer largeFaint;
|
||||||
|
private readonly CircularContainer smallFaint;
|
||||||
|
private readonly CircularContainer directionalGlow1;
|
||||||
|
private readonly CircularContainer directionalGlow2;
|
||||||
|
|
||||||
|
public HitExplosion()
|
||||||
{
|
{
|
||||||
Size = new Vector2(20);
|
Size = new Vector2(20);
|
||||||
Anchor = Anchor.TopCentre;
|
Anchor = Anchor.TopCentre;
|
||||||
Origin = Anchor.BottomCentre;
|
Origin = Anchor.BottomCentre;
|
||||||
|
|
||||||
Color4 objectColour = fruit.AccentColour.Value;
|
|
||||||
|
|
||||||
// scale roughly in-line with visual appearance of notes
|
// scale roughly in-line with visual appearance of notes
|
||||||
|
|
||||||
const float angle_variangle = 15; // should be less than 45
|
|
||||||
|
|
||||||
const float roundness = 100;
|
|
||||||
|
|
||||||
const float initial_height = 10;
|
const float initial_height = 10;
|
||||||
|
|
||||||
var colour = Interpolation.ValueAt(0.4f, objectColour, Color4.White, 0, 1);
|
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
largeFaint = new CircularContainer
|
largeFaint = new CircularContainer
|
||||||
@ -42,33 +50,17 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
// we want our size to be very small so the glow dominates it.
|
|
||||||
Size = new Vector2(0.8f),
|
|
||||||
Blending = BlendingParameters.Additive,
|
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,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
new CircularContainer
|
smallFaint = new CircularContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
Blending = BlendingParameters.Additive,
|
Blending = BlendingParameters.Additive,
|
||||||
EdgeEffect = new EdgeEffectParameters
|
|
||||||
{
|
|
||||||
Type = EdgeEffectType.Glow,
|
|
||||||
Colour = Interpolation.ValueAt(0.6f, objectColour, Color4.White, 0, 1),
|
|
||||||
Roundness = 20,
|
|
||||||
Radius = 50,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
new CircularContainer
|
directionalGlow1 = new CircularContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
@ -76,16 +68,8 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
Masking = true,
|
Masking = true,
|
||||||
Size = new Vector2(0.01f, initial_height),
|
Size = new Vector2(0.01f, initial_height),
|
||||||
Blending = BlendingParameters.Additive,
|
Blending = BlendingParameters.Additive,
|
||||||
Rotation = RNG.NextSingle(-angle_variangle, angle_variangle),
|
|
||||||
EdgeEffect = new EdgeEffectParameters
|
|
||||||
{
|
|
||||||
Type = EdgeEffectType.Glow,
|
|
||||||
Colour = colour,
|
|
||||||
Roundness = roundness,
|
|
||||||
Radius = 40,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
new CircularContainer
|
directionalGlow2 = new CircularContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
@ -93,30 +77,57 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
Masking = true,
|
Masking = true,
|
||||||
Size = new Vector2(0.01f, initial_height),
|
Size = new Vector2(0.01f, initial_height),
|
||||||
Blending = BlendingParameters.Additive,
|
Blending = BlendingParameters.Additive,
|
||||||
Rotation = RNG.NextSingle(-angle_variangle, angle_variangle),
|
|
||||||
EdgeEffect = new EdgeEffectParameters
|
|
||||||
{
|
|
||||||
Type = EdgeEffectType.Glow,
|
|
||||||
Colour = colour,
|
|
||||||
Roundness = roundness,
|
|
||||||
Radius = 40,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void PrepareForUse()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.PrepareForUse();
|
||||||
|
|
||||||
const double duration = 400;
|
const double duration = 400;
|
||||||
|
|
||||||
|
// we want our size to be very small so the glow dominates it.
|
||||||
|
largeFaint.Size = new Vector2(0.8f);
|
||||||
largeFaint
|
largeFaint
|
||||||
.ResizeTo(largeFaint.Size * new Vector2(5, 1), duration, Easing.OutQuint)
|
.ResizeTo(largeFaint.Size * new Vector2(5, 1), duration, Easing.OutQuint)
|
||||||
.FadeOut(duration * 2);
|
.FadeOut(duration * 2);
|
||||||
|
|
||||||
|
const float angle_variangle = 15; // should be less than 45
|
||||||
|
directionalGlow1.Rotation = RNG.NextSingle(-angle_variangle, angle_variangle);
|
||||||
|
directionalGlow2.Rotation = RNG.NextSingle(-angle_variangle, angle_variangle);
|
||||||
|
|
||||||
this.FadeInFromZero(50).Then().FadeOut(duration, Easing.Out);
|
this.FadeInFromZero(50).Then().FadeOut(duration, Easing.Out);
|
||||||
Expire(true);
|
Expire(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onColourChanged()
|
||||||
|
{
|
||||||
|
const float roundness = 100;
|
||||||
|
|
||||||
|
largeFaint.EdgeEffect = new EdgeEffectParameters
|
||||||
|
{
|
||||||
|
Type = EdgeEffectType.Glow,
|
||||||
|
Colour = Interpolation.ValueAt(0.1f, objectColour, Color4.White, 0, 1).Opacity(0.3f),
|
||||||
|
Roundness = 160,
|
||||||
|
Radius = 200,
|
||||||
|
};
|
||||||
|
|
||||||
|
smallFaint.EdgeEffect = new EdgeEffectParameters
|
||||||
|
{
|
||||||
|
Type = EdgeEffectType.Glow,
|
||||||
|
Colour = Interpolation.ValueAt(0.6f, objectColour, Color4.White, 0, 1),
|
||||||
|
Roundness = 20,
|
||||||
|
Radius = 50,
|
||||||
|
};
|
||||||
|
|
||||||
|
directionalGlow1.EdgeEffect = directionalGlow2.EdgeEffect = new EdgeEffectParameters
|
||||||
|
{
|
||||||
|
Type = EdgeEffectType.Glow,
|
||||||
|
Colour = Interpolation.ValueAt(0.4f, objectColour, Color4.White, 0, 1),
|
||||||
|
Roundness = roundness,
|
||||||
|
Radius = 40,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user