mirror of
https://github.com/ppy/osu.git
synced 2025-03-23 08:27:23 +08:00
Restructure explosion to ensure proper lifetime bounds
This commit is contained in:
parent
8c8a64fe6e
commit
4bcbe6ac90
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -15,11 +14,8 @@ using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Skinning.Default
|
||||
{
|
||||
public class DefaultHitExplosion : CompositeDrawable
|
||||
public class DefaultHitExplosion : CompositeDrawable, IHitExplosion
|
||||
{
|
||||
[Resolved]
|
||||
private Bindable<HitExplosionEntry> entryBindable { get; set; }
|
||||
|
||||
private CircularContainer largeFaint;
|
||||
private CircularContainer smallFaint;
|
||||
private CircularContainer directionalGlow1;
|
||||
@ -74,14 +70,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Default
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
entryBindable.BindValueChanged(entry => apply(entry.NewValue), true);
|
||||
}
|
||||
|
||||
private void apply(HitExplosionEntry entry)
|
||||
public void Animate(HitExplosionEntry entry)
|
||||
{
|
||||
if (entry == null)
|
||||
return;
|
||||
@ -110,7 +99,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Default
|
||||
directionalGlow1.Rotation = StatelessRNG.NextSingle(-angle_variangle, angle_variangle, randomSeed, 4);
|
||||
directionalGlow2.Rotation = StatelessRNG.NextSingle(-angle_variangle, angle_variangle, randomSeed, 5);
|
||||
|
||||
this.FadeInFromZero(50).Then().FadeOut(duration, Easing.Out).Expire();
|
||||
this.FadeInFromZero(50).Then().FadeOut(duration, Easing.Out);
|
||||
}
|
||||
|
||||
private void setColour(Color4 objectColour)
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
@ -14,14 +13,11 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Skinning.Legacy
|
||||
{
|
||||
public class LegacyHitExplosion : CompositeDrawable
|
||||
public class LegacyHitExplosion : CompositeDrawable, IHitExplosion
|
||||
{
|
||||
[Resolved]
|
||||
private Catcher catcher { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private Bindable<HitExplosionEntry> entryBindable { get; set; }
|
||||
|
||||
private const float catch_margin = (1 - Catcher.ALLOWED_CATCH_RANGE) / 2;
|
||||
|
||||
private readonly Sprite explosion1;
|
||||
@ -62,14 +58,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
|
||||
explosion2.Texture = defaultLegacySkin.GetTexture("scoreboard-explosion-1");
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
entryBindable.BindValueChanged(entry => apply(entry.NewValue), true);
|
||||
}
|
||||
|
||||
private void apply(HitExplosionEntry entry)
|
||||
public void Animate(HitExplosionEntry entry)
|
||||
{
|
||||
if (entry == null)
|
||||
return;
|
||||
@ -88,15 +77,17 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
|
||||
explosion1.Scale = new Vector2(1, 0.9f);
|
||||
explosion1.Position = new Vector2(explosionOffset, 0);
|
||||
|
||||
explosion1.FadeOut(300);
|
||||
explosion1.FadeOutFromOne(300);
|
||||
explosion1.ScaleTo(new Vector2(20 * scale, 1.1f), 160, Easing.Out);
|
||||
}
|
||||
|
||||
explosion2.Scale = new Vector2(0.9f, 1);
|
||||
explosion2.Position = new Vector2(explosionOffset, 0);
|
||||
|
||||
explosion2.FadeOut(700);
|
||||
explosion2.FadeOutFromOne(700);
|
||||
explosion2.ScaleTo(new Vector2(0.9f, 1.3f), 500, Easing.Out);
|
||||
|
||||
this.Delay(700).FadeOutFromOne();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Catch.Skinning.Default;
|
||||
using osu.Game.Rulesets.Objects.Pooling;
|
||||
@ -12,8 +11,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
{
|
||||
public class HitExplosion : PoolableDrawableWithLifetime<HitExplosionEntry>
|
||||
{
|
||||
[Cached]
|
||||
private Bindable<HitExplosionEntry> bindableEntry { get; set; } = new Bindable<HitExplosionEntry>();
|
||||
private SkinnableDrawable skinnableExplosion;
|
||||
|
||||
public HitExplosion()
|
||||
{
|
||||
@ -25,7 +23,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = new SkinnableDrawable(new CatchSkinComponent(CatchSkinComponents.HitExplosion), _ => new DefaultHitExplosion())
|
||||
InternalChild = skinnableExplosion = new SkinnableDrawable(new CatchSkinComponent(CatchSkinComponents.HitExplosion), _ => new DefaultHitExplosion())
|
||||
{
|
||||
CentreComponent = false,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
@ -37,7 +35,11 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
{
|
||||
base.OnApply(entry);
|
||||
|
||||
bindableEntry.Value = entry;
|
||||
ApplyTransformsAt(double.MinValue, true);
|
||||
ClearTransforms(true);
|
||||
|
||||
(skinnableExplosion.Drawable as IHitExplosion)?.Animate(entry);
|
||||
LifetimeEnd = skinnableExplosion.Drawable.LatestTransformEndTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
16
osu.Game.Rulesets.Catch/UI/IHitExplosion.cs
Normal file
16
osu.Game.Rulesets.Catch/UI/IHitExplosion.cs
Normal file
@ -0,0 +1,16 @@
|
||||
// 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.
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Common interface for all hit explosion skinnables.
|
||||
/// </summary>
|
||||
public interface IHitExplosion
|
||||
{
|
||||
/// <summary>
|
||||
/// Begins animating this <see cref="IHitExplosion"/>.
|
||||
/// </summary>
|
||||
void Animate(HitExplosionEntry entry);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user