mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 14:25:05 +08:00
Remove ParticleJet
This commit is contained in:
parent
99eff4f41f
commit
cfcb46034c
@ -1,61 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
using NUnit.Framework;
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Testing;
|
|
||||||
using osu.Game.Graphics.Particles;
|
|
||||||
using osu.Game.Skinning;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
|
||||||
{
|
|
||||||
[TestFixture]
|
|
||||||
public class TestSceneParticleJet : OsuTestScene
|
|
||||||
{
|
|
||||||
private ParticleJet jet;
|
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private SkinManager skinManager { get; set; }
|
|
||||||
|
|
||||||
public TestSceneParticleJet()
|
|
||||||
{
|
|
||||||
AddStep("create", () =>
|
|
||||||
{
|
|
||||||
Child = jet = createJet();
|
|
||||||
});
|
|
||||||
|
|
||||||
AddToggleStep("toggle spawning", value => jet.Active.Value = value);
|
|
||||||
}
|
|
||||||
|
|
||||||
[SetUpSteps]
|
|
||||||
public void SetUpSteps()
|
|
||||||
{
|
|
||||||
AddStep("create jet", () => Child = jet = createJet());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void TestPresence()
|
|
||||||
{
|
|
||||||
AddStep("start jet", () => jet.Active.Value = true);
|
|
||||||
AddAssert("is present", () => jet.IsPresent);
|
|
||||||
|
|
||||||
AddWaitStep("wait for some particles", 3);
|
|
||||||
AddStep("stop jet", () => jet.Active.Value = false);
|
|
||||||
|
|
||||||
AddWaitStep("wait for clean screen", 5);
|
|
||||||
AddAssert("is not present", () => !jet.IsPresent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ParticleJet createJet()
|
|
||||||
{
|
|
||||||
return new ParticleJet(skinManager.DefaultLegacySkin.GetTexture("star2"), 180)
|
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
RelativePositionAxes = Axes.Y,
|
|
||||||
Y = -0.1f,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
94
osu.Game.Tests/Visual/Gameplay/TestSceneParticleSpewer.cs
Normal file
94
osu.Game.Tests/Visual/Gameplay/TestSceneParticleSpewer.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
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.Particles;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestSceneParticleSpewer : OsuTestScene
|
||||||
|
{
|
||||||
|
private TestParticleSpewer spewer;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private SkinManager skinManager { get; set; }
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
Child = spewer = createSpewer();
|
||||||
|
|
||||||
|
AddToggleStep("toggle spawning", value => spewer.Active.Value = value);
|
||||||
|
AddSliderStep("particle gravity", 0f, 250f, 0f, value => spewer.Gravity = value);
|
||||||
|
AddSliderStep("particle velocity", 0f, 500f, 250f, value => spewer.MaxVelocity = value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[SetUpSteps]
|
||||||
|
public void SetUpSteps()
|
||||||
|
{
|
||||||
|
AddStep("create jet", () => Child = spewer = createSpewer());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestPresence()
|
||||||
|
{
|
||||||
|
AddStep("start jet", () => spewer.Active.Value = true);
|
||||||
|
AddAssert("is present", () => spewer.IsPresent);
|
||||||
|
|
||||||
|
AddWaitStep("wait for some particles", 3);
|
||||||
|
AddStep("stop jet", () => spewer.Active.Value = false);
|
||||||
|
|
||||||
|
AddWaitStep("wait for clean screen", 8);
|
||||||
|
AddAssert("is not present", () => !spewer.IsPresent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private TestParticleSpewer createSpewer()
|
||||||
|
{
|
||||||
|
return new TestParticleSpewer(skinManager.DefaultLegacySkin.GetTexture("star2"))
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestParticleSpewer : ParticleSpewer
|
||||||
|
{
|
||||||
|
private const int lifetime = 1500;
|
||||||
|
private const int rate = 250;
|
||||||
|
|
||||||
|
public float Gravity = 0;
|
||||||
|
public float MaxVelocity = 250;
|
||||||
|
|
||||||
|
protected override float ParticleGravity => Gravity;
|
||||||
|
|
||||||
|
public TestParticleSpewer(Texture texture)
|
||||||
|
: base(texture, rate, lifetime)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override FallingParticle SpawnParticle()
|
||||||
|
{
|
||||||
|
var p = base.SpawnParticle();
|
||||||
|
p.Velocity = new Vector2(
|
||||||
|
RNG.NextSingle(-MaxVelocity, MaxVelocity),
|
||||||
|
RNG.NextSingle(-MaxVelocity, MaxVelocity)
|
||||||
|
);
|
||||||
|
p.Duration = RNG.NextSingle(lifetime);
|
||||||
|
p.StartAngle = RNG.NextSingle(MathF.PI * 2);
|
||||||
|
p.EndAngle = RNG.NextSingle(MathF.PI * 2);
|
||||||
|
p.EndScale = RNG.NextSingle(0.5f, 1.5f);
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,48 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Graphics.Textures;
|
|
||||||
using osu.Framework.Utils;
|
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Graphics.Particles
|
|
||||||
{
|
|
||||||
public class ParticleJet : ParticleSpewer
|
|
||||||
{
|
|
||||||
private const int particles_per_second = 80;
|
|
||||||
private const double particle_lifetime = 500;
|
|
||||||
private const int angle_spread = 10;
|
|
||||||
private const float velocity_min = 1300f;
|
|
||||||
private const float velocity_max = 1500f;
|
|
||||||
|
|
||||||
private readonly int angle;
|
|
||||||
|
|
||||||
protected override float ParticleGravity => 750f;
|
|
||||||
|
|
||||||
public ParticleJet(Texture texture, int angle)
|
|
||||||
: base(texture, particles_per_second, particle_lifetime)
|
|
||||||
{
|
|
||||||
this.angle = angle;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override FallingParticle SpawnParticle()
|
|
||||||
{
|
|
||||||
var p = base.SpawnParticle();
|
|
||||||
|
|
||||||
var directionRads = MathUtils.DegreesToRadians(
|
|
||||||
RNG.NextSingle(angle - angle_spread / 2, angle + angle_spread / 2)
|
|
||||||
);
|
|
||||||
var direction = new Vector2(MathF.Sin(directionRads), MathF.Cos(directionRads));
|
|
||||||
|
|
||||||
p.StartPosition = OriginPosition;
|
|
||||||
p.Duration = RNG.NextSingle((float)particle_lifetime * 0.8f, (float)particle_lifetime);
|
|
||||||
p.Velocity = direction * new Vector2(RNG.NextSingle(velocity_min, velocity_max));
|
|
||||||
p.StartAngle = RNG.NextSingle(-2f, 2f);
|
|
||||||
p.EndAngle = RNG.NextSingle(-2f, 2f);
|
|
||||||
p.EndScale = 2f;
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user