public void CreateFire(float x, float y, int intensity) { Vector2 Position; Texture2D particleTexture = game.Content.Load <Texture2D>("art/particles/Cloud1-32"); //Texture2D particleTexture = game.Content.Load<Texture2D>("art/particles/Cloud1-128"); //intensity = 100; //Red Particles int r = rand.Next(210, 250); int g = rand.Next(30, 90); int b = rand.Next(30, 50); for (int i = 0; i < intensity / 3; i++) { Position = new Vector2(x = NextFloat(rand, x + .75f, x - .75f), y = NextFloat(rand, y + .75f, y - .75f)) * game.physics_scale; float speed = 3f * (1f - 1 / NextFloat(rand, 1f, 20f)); var state = new ParticleState() { Velocity = NextVector2(rand, speed, speed / 4), Type = ParticleType.Fire, LengthMultiplier = 8f }; game.ParticleManager.CreateParticle(particleTexture, Position, Color.FromNonPremultiplied(r, g, b, 255), 150f, new Vector2(1.0f), state); } // Yellow Particles r = rand.Next(220, 240); g = rand.Next(170, 225); b = rand.Next(0, 40); //particleTexture = game.Content.Load<Texture2D>("art/particles/Cloud2-128"); for (int i = 0; i < intensity / 4; i++) { Position = new Vector2(x = NextFloat(rand, x + .5f, x - .5f), y = NextFloat(rand, y + .5f, y - .5f)) * game.physics_scale; float speed = 3f * (1f - 1 / NextFloat(rand, 1f, 5f)); var state = new ParticleState() { Velocity = NextVector2(rand, speed, speed / 7), Type = ParticleType.Fire, LengthMultiplier = 8f }; game.ParticleManager.CreateParticle(particleTexture, Position, Color.FromNonPremultiplied(r, g, b, 255), 150f, new Vector2(NextFloat(rand, 0.5f, 1f)), state); } //particleTexture = game.Content.Load<Texture2D>("art/particles/Cloud3-128"); //particleTexture = game.Content.Load<Texture2D>("art/particle"); for (int i = 0; i < intensity / 7; i++) { Position = new Vector2(x = NextFloat(rand, x + .25f, x - .25f), y = NextFloat(rand, y + .25f, y - .25f)) * game.physics_scale; float speed = .5f * (1f - 1 / NextFloat(rand, 1f, 5f)); var state = new ParticleState() { Velocity = NextVector2(rand, speed * 3, speed / 5), Type = ParticleType.Fire, LengthMultiplier = 8f }; game.ParticleManager.CreateParticle(particleTexture, Position, Color.FromNonPremultiplied(255, 255, 255, 200), 150f, new Vector2(NextFloat(rand, 0.5f, 1f)), state); } }
public static ParticleState GetRandom(float minVel, float maxVel) { var state = new ParticleState(); double theta = rand.NextDouble() * 2 * Math.PI; float length = (float)rand.NextDouble() * (minVel - maxVel) + minVel; state.Velocity = new Vector2(length * (float)Math.Cos(theta), length * (float)Math.Sin(theta)); state.Type = ParticleType.None; state.LengthMultiplier = 1; return(state); }
public void CreateExplosion(int x, int y, int count, int r, int b, int g) { Vector2 Position = new Vector2(x, y) * game.physics_scale; //Texture2D particleTexture = game.Content.Load<Texture2D>("art/particle"); Texture2D particleTexture = game.Content.Load <Texture2D>("art/particles/Glow"); for (int i = 0; i < count; i++) { float speed = 6f * (1f - 1 / NextFloat(rand, 1f, 10f)); var state = new ParticleState() { Velocity = NextVector2(rand, speed, speed), Type = ParticleType.Explosion, LengthMultiplier = 1f }; game.ParticleManager.CreateParticle(particleTexture, Position, Color.FromNonPremultiplied(r, g, b, 255), 190f, new Vector2(1.0f), state); } }
public void CreateSprinkler(float x, float y, int intensity) { Vector2 Position = new Vector2(x, y) * game.physics_scale; Texture2D particleTexture = game.Content.Load <Texture2D>("art/particles/Glow"); int r = 32; int g = 50; int b = 50; for (int i = 0; i < intensity; i++) { float speed = 6f * (1f - 1 / NextFloat(rand, 1f, 10f)); var state = new ParticleState() { Velocity = NextVector2(rand, speed, speed), Type = ParticleType.Explosion, LengthMultiplier = 1f }; game.ParticleManager.CreateParticle(particleTexture, Position, Color.FromNonPremultiplied(r, g, b, 128), 190f, new Vector2(1.0f), state); } }
public void CreateParticle(Texture2D texture, Vector2 position, Color tint, float duration, Vector2 scale, ParticleState state, float theta = 0) { Particle particle; if (particleList.Count == particleList.Capacity) { //Over write the oldest particle = particleList[0]; particleList.Start++; } else { particle = particleList[particleList.Count]; particleList.Count++; } particle.Texture = texture; particle.Position = position; particle.Tint = tint; particle.Duration = duration; particle.PercentLife = 1f; particle.Scale = scale; particle.Orientation = theta; particle.State = state; }