mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 16:02:55 +08:00
Make particles additive and consume in judgement explosions
This commit is contained in:
parent
9df93e1f18
commit
9d04ce75cc
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
@ -26,11 +27,19 @@ namespace osu.Game.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
public void Restart()
|
||||
{
|
||||
foreach (var p in InternalChildren.OfType<Particle>())
|
||||
p.Play();
|
||||
}
|
||||
|
||||
private class Particle : Sprite
|
||||
{
|
||||
private readonly double duration;
|
||||
private readonly float direction;
|
||||
|
||||
public override bool RemoveWhenNotAlive => false;
|
||||
|
||||
private Vector2 positionForOffset(float offset) => new Vector2(
|
||||
(float)(offset * Math.Sin(direction)),
|
||||
(float)(offset * Math.Cos(direction))
|
||||
@ -40,18 +49,25 @@ namespace osu.Game.Graphics
|
||||
{
|
||||
this.duration = duration;
|
||||
this.direction = direction;
|
||||
Anchor = Anchor.Centre;
|
||||
|
||||
Origin = Anchor.Centre;
|
||||
Blending = BlendingParameters.Additive;
|
||||
|
||||
RelativePositionAxes = Axes.Both;
|
||||
Position = positionForOffset(0);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
Play();
|
||||
}
|
||||
|
||||
this.MoveTo(positionForOffset(1), duration);
|
||||
this.FadeOut(duration);
|
||||
public void Play()
|
||||
{
|
||||
this.MoveTo(new Vector2(0.5f));
|
||||
this.MoveTo(new Vector2(0.5f) + positionForOffset(0.5f), duration);
|
||||
|
||||
this.FadeOutFromOne(duration);
|
||||
Expire();
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,9 @@ using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Animations;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osuTK;
|
||||
@ -20,7 +22,9 @@ namespace osu.Game.Skinning
|
||||
|
||||
private readonly Drawable mainPiece;
|
||||
|
||||
public LegacyJudgementPieceNew(HitResult result, Func<Drawable> createMainDrawable, Func<Drawable> createParticleDrawable)
|
||||
private readonly ParticleExplosion particles;
|
||||
|
||||
public LegacyJudgementPieceNew(HitResult result, Func<Drawable> createMainDrawable, Texture particleTexture)
|
||||
{
|
||||
this.result = result;
|
||||
|
||||
@ -36,6 +40,17 @@ namespace osu.Game.Skinning
|
||||
})
|
||||
};
|
||||
|
||||
if (particleTexture != null)
|
||||
{
|
||||
AddInternal(particles = new ParticleExplosion(particleTexture, 150, 1600)
|
||||
{
|
||||
Size = new Vector2(140),
|
||||
Depth = float.MaxValue,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
});
|
||||
}
|
||||
|
||||
if (result != HitResult.Miss)
|
||||
{
|
||||
//new judgement shows old as a temporary effect
|
||||
@ -54,6 +69,13 @@ namespace osu.Game.Skinning
|
||||
|
||||
animation?.GotoFrame(0);
|
||||
|
||||
if (particles != null)
|
||||
{
|
||||
// start the particles already some way into their animation to break cluster away from centre.
|
||||
using (particles.BeginDelayedSequence(-100, true))
|
||||
particles.Restart();
|
||||
}
|
||||
|
||||
const double fade_in_length = 120;
|
||||
const double fade_out_delay = 500;
|
||||
const double fade_out_length = 600;
|
||||
|
@ -377,7 +377,7 @@ namespace osu.Game.Skinning
|
||||
if (createDrawable() != null)
|
||||
{
|
||||
if (Configuration.LegacyVersion > 1)
|
||||
return new LegacyJudgementPieceNew(resultComponent.Component, createDrawable, () => getParticleDrawable(resultComponent.Component));
|
||||
return new LegacyJudgementPieceNew(resultComponent.Component, createDrawable, getParticleTexture(resultComponent.Component));
|
||||
else
|
||||
return new LegacyJudgementPieceOld(resultComponent.Component, createDrawable);
|
||||
}
|
||||
@ -388,18 +388,18 @@ namespace osu.Game.Skinning
|
||||
return this.GetAnimation(component.LookupName, false, false);
|
||||
}
|
||||
|
||||
private Drawable getParticleDrawable(HitResult result)
|
||||
private Texture getParticleTexture(HitResult result)
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case HitResult.Meh:
|
||||
return this.GetAnimation("particle50", false, false);
|
||||
return GetTexture("particle50");
|
||||
|
||||
case HitResult.Ok:
|
||||
return this.GetAnimation("particle100", false, false);
|
||||
return GetTexture("particle100");
|
||||
|
||||
case HitResult.Great:
|
||||
return this.GetAnimation("particle300", false, false);
|
||||
return GetTexture("particle300");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user