mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Remove abstract from ParticleSpewer
This commit is contained in:
@ -5,7 +5,6 @@ using System;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics;
|
||||
@ -17,7 +16,12 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[TestFixture]
|
||||
public class TestSceneParticleSpewer : OsuTestScene
|
||||
{
|
||||
private TestParticleSpewer spewer;
|
||||
private const int max_particle_duration = 1500;
|
||||
|
||||
private float particleMaxVelocity = 0.5f;
|
||||
private Vector2 particleSpawnPosition = new Vector2(0.5f);
|
||||
|
||||
private ParticleSpewer spewer;
|
||||
|
||||
[Resolved]
|
||||
private SkinManager skinManager { get; set; }
|
||||
@ -28,11 +32,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
Child = spewer = createSpewer();
|
||||
|
||||
AddToggleStep("toggle spawning", value => spewer.Active.Value = value);
|
||||
AddSliderStep("particle gravity", 0f, 1f, 0f, value => spewer.Gravity = value);
|
||||
AddSliderStep("particle velocity", 0f, 1f, 0.5f, value => spewer.MaxVelocity = value);
|
||||
AddSliderStep("particle velocity", 0f, 1f, 0.5f, value => particleMaxVelocity = value);
|
||||
AddSliderStep("particle gravity", 0f, 1f, 0f, value => spewer.ParticleGravity = value);
|
||||
AddStep("move to new location", () =>
|
||||
{
|
||||
spewer.TransformTo(nameof(spewer.SpawnPosition), new Vector2(RNG.NextSingle(), RNG.NextSingle()), 1000, Easing.Out);
|
||||
this.TransformTo(nameof(particleSpawnPosition), new Vector2(RNG.NextSingle(), RNG.NextSingle()), 1000, Easing.Out);
|
||||
});
|
||||
}
|
||||
|
||||
@ -55,47 +59,29 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddAssert("is not present", () => !spewer.IsPresent);
|
||||
}
|
||||
|
||||
private TestParticleSpewer createSpewer() =>
|
||||
new TestParticleSpewer(skinManager.DefaultLegacySkin.GetTexture("star2"))
|
||||
private ParticleSpewer createSpewer() =>
|
||||
new ParticleSpewer(skinManager.DefaultLegacySkin.GetTexture("star2"), 1500, max_particle_duration)
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Position = new Vector2(0.5f),
|
||||
Size = new Vector2(0.5f),
|
||||
CreateParticle = createParticle,
|
||||
};
|
||||
|
||||
private class TestParticleSpewer : ParticleSpewer
|
||||
{
|
||||
private const int lifetime = 1500;
|
||||
private const int rate = 250;
|
||||
|
||||
public float Gravity;
|
||||
|
||||
public float MaxVelocity = 0.25f;
|
||||
|
||||
public Vector2 SpawnPosition { get; set; } = new Vector2(0.5f);
|
||||
|
||||
protected override float ParticleGravity => Gravity;
|
||||
|
||||
public TestParticleSpewer(Texture texture)
|
||||
: base(texture, rate, lifetime)
|
||||
private ParticleSpewer.FallingParticle? createParticle() =>
|
||||
new ParticleSpewer.FallingParticle
|
||||
{
|
||||
}
|
||||
|
||||
protected override FallingParticle CreateParticle() =>
|
||||
new FallingParticle
|
||||
{
|
||||
Velocity = new Vector2(
|
||||
RNG.NextSingle(-MaxVelocity, MaxVelocity),
|
||||
RNG.NextSingle(-MaxVelocity, MaxVelocity)
|
||||
),
|
||||
StartPosition = SpawnPosition,
|
||||
Duration = RNG.NextSingle(lifetime),
|
||||
StartAngle = RNG.NextSingle(MathF.PI * 2),
|
||||
EndAngle = RNG.NextSingle(MathF.PI * 2),
|
||||
EndScale = RNG.NextSingle(0.5f, 1.5f)
|
||||
};
|
||||
}
|
||||
Velocity = new Vector2(
|
||||
RNG.NextSingle(-particleMaxVelocity, particleMaxVelocity),
|
||||
RNG.NextSingle(-particleMaxVelocity, particleMaxVelocity)
|
||||
),
|
||||
StartPosition = particleSpawnPosition,
|
||||
Duration = RNG.NextSingle(max_particle_duration),
|
||||
StartAngle = RNG.NextSingle(MathF.PI * 2),
|
||||
EndAngle = RNG.NextSingle(MathF.PI * 2),
|
||||
EndScale = RNG.NextSingle(0.5f, 1.5f)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user