Added NoTrail, Slowmotion and BulletFreezeRemove Pickups

Also refactored Extinguisher to remove particles from the end (still wonky though)
This commit is contained in:
2022-04-19 23:21:03 +02:00
parent e2511e2d53
commit 095fc0742b
19 changed files with 5467 additions and 45 deletions

View File

@@ -4,6 +4,7 @@ using UnityEngine;
public class Extinguisher : Pickup
{
public ParticleSystem extinguishEffect;
public Player player;
[SerializeField]
@@ -11,13 +12,38 @@ public class Extinguisher : Pickup
public override void OnPickup()
{
// we have to stop the particle system before making changes
ParticleSystem system = player.trail.GetComponent<ParticleSystem>();
system.Stop();
ParticleSystem particleSystem = player.trail.GetComponent<ParticleSystem>();
int particleCount = particleSystem.particleCount;
ParticleSystem.Particle[] particles = new ParticleSystem.Particle[particleCount];
particleSystem.GetParticles(particles);
system.startLifetime *= amount;
for (int i = 0; i < particleCount; i++)
{
if (particles[i].remainingLifetime < particleSystem.main.startLifetime.constant * 0.5f)
{
particles[i].remainingLifetime = 0.0f;
}
//instantiate freeze particles at the position of the particle
}
particleSystem.SetParticles(particles, particleCount);
StartCoroutine(SpawnEffectsCoroutine(particles, particleCount, particleSystem));
}
IEnumerator SpawnEffectsCoroutine(ParticleSystem.Particle[] particles, int count, ParticleSystem system)
{
system.Play();
for (int i = 0; i < count; i+=20)
{
if (particles[i].remainingLifetime < system.main.startLifetime.constant * 0.5f)
{
//instantiate freeze particles at the position of the particle
Instantiate(extinguishEffect, particles[i].position, Quaternion.identity);
yield return null;
}
}
}
// Start is called before the first frame update