mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 11:12:59 +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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
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 class Particle : Sprite
|
||||||
{
|
{
|
||||||
private readonly double duration;
|
private readonly double duration;
|
||||||
private readonly float direction;
|
private readonly float direction;
|
||||||
|
|
||||||
|
public override bool RemoveWhenNotAlive => false;
|
||||||
|
|
||||||
private Vector2 positionForOffset(float offset) => new Vector2(
|
private Vector2 positionForOffset(float offset) => new Vector2(
|
||||||
(float)(offset * Math.Sin(direction)),
|
(float)(offset * Math.Sin(direction)),
|
||||||
(float)(offset * Math.Cos(direction))
|
(float)(offset * Math.Cos(direction))
|
||||||
@ -40,18 +49,25 @@ namespace osu.Game.Graphics
|
|||||||
{
|
{
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
this.direction = direction;
|
this.direction = direction;
|
||||||
Anchor = Anchor.Centre;
|
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
Blending = BlendingParameters.Additive;
|
||||||
|
|
||||||
RelativePositionAxes = Axes.Both;
|
RelativePositionAxes = Axes.Both;
|
||||||
Position = positionForOffset(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
Play();
|
||||||
|
}
|
||||||
|
|
||||||
this.MoveTo(positionForOffset(1), duration);
|
public void Play()
|
||||||
this.FadeOut(duration);
|
{
|
||||||
|
this.MoveTo(new Vector2(0.5f));
|
||||||
|
this.MoveTo(new Vector2(0.5f) + positionForOffset(0.5f), duration);
|
||||||
|
|
||||||
|
this.FadeOutFromOne(duration);
|
||||||
Expire();
|
Expire();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,9 @@ using System;
|
|||||||
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.Textures;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -20,7 +22,9 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
private readonly Drawable mainPiece;
|
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;
|
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)
|
if (result != HitResult.Miss)
|
||||||
{
|
{
|
||||||
//new judgement shows old as a temporary effect
|
//new judgement shows old as a temporary effect
|
||||||
@ -54,6 +69,13 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
animation?.GotoFrame(0);
|
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_in_length = 120;
|
||||||
const double fade_out_delay = 500;
|
const double fade_out_delay = 500;
|
||||||
const double fade_out_length = 600;
|
const double fade_out_length = 600;
|
||||||
|
@ -377,7 +377,7 @@ namespace osu.Game.Skinning
|
|||||||
if (createDrawable() != null)
|
if (createDrawable() != null)
|
||||||
{
|
{
|
||||||
if (Configuration.LegacyVersion > 1)
|
if (Configuration.LegacyVersion > 1)
|
||||||
return new LegacyJudgementPieceNew(resultComponent.Component, createDrawable, () => getParticleDrawable(resultComponent.Component));
|
return new LegacyJudgementPieceNew(resultComponent.Component, createDrawable, getParticleTexture(resultComponent.Component));
|
||||||
else
|
else
|
||||||
return new LegacyJudgementPieceOld(resultComponent.Component, createDrawable);
|
return new LegacyJudgementPieceOld(resultComponent.Component, createDrawable);
|
||||||
}
|
}
|
||||||
@ -388,18 +388,18 @@ namespace osu.Game.Skinning
|
|||||||
return this.GetAnimation(component.LookupName, false, false);
|
return this.GetAnimation(component.LookupName, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getParticleDrawable(HitResult result)
|
private Texture getParticleTexture(HitResult result)
|
||||||
{
|
{
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
case HitResult.Meh:
|
case HitResult.Meh:
|
||||||
return this.GetAnimation("particle50", false, false);
|
return GetTexture("particle50");
|
||||||
|
|
||||||
case HitResult.Ok:
|
case HitResult.Ok:
|
||||||
return this.GetAnimation("particle100", false, false);
|
return GetTexture("particle100");
|
||||||
|
|
||||||
case HitResult.Great:
|
case HitResult.Great:
|
||||||
return this.GetAnimation("particle300", false, false);
|
return GetTexture("particle300");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user