Пример #1
0
        //0 lifetime = infinity
        public ParticleSystem Spawn(ParticleSystemInfo psInfo, Vector2 origin, float lifetime = 0)
        {
            ParticleSystem temp = freeParticleSystems.Dequeue();

            temp.Initialize(psInfo, origin, lifetime);
            temp.LoadContent(contentManager, device);
            particleSystems.Add(temp);
            return(temp);
        }
Пример #2
0
 public void Initialize(ParticleSystemInfo particleInfo, Vector2 origin, float lifetime)
 {
     for (var i = particles.Count - 1; i > 0; i--)
     {
         particles[i].isAlive = false;
     }
     status            = ParticleStatus.Alive;
     this.particleInfo = particleInfo;
     this.origin       = origin;
     makeParticles();
     this.lifetime     = lifetime;
     this.time_elapsed = 0;
 }
Пример #3
0
        public void AddFireSmallInfo()
        {
            ParticleSystemInfo fireSmallParticle = new ParticleSystemInfo();

            fireSmallParticle.TextureName  = "fire";
            fireSmallParticle.name         = "fireSmall";
            fireSmallParticle.maxParticles = 40;
            fireSmallParticle.minParticles = 20;

            fireSmallParticle.minLife = 0f;
            fireSmallParticle.maxLife = .1f;

            fireSmallParticle.minVelocity = new Vector2(-10, -10);
            fireSmallParticle.maxVelocity = new Vector2(10, 10);

            fireSmallParticle.minAcceleration = new Vector2(0, 0);
            fireSmallParticle.maxAcceleration = new Vector2(0, 0);

            fireSmallParticle.minRotation = 0;
            fireSmallParticle.maxRotation = 2 * (float)Math.PI;

            // Set gravity upside down, so the flames will 'fall' upward.
            fireSmallParticle.Gravity = new Vector2(0, 0);

            fireSmallParticle.MinColor = new Color(0, 0, 0, 255);
            fireSmallParticle.MaxColor = new Color(255, 255, 255, 255);

            fireSmallParticle.MinStartScale = .1f;
            fireSmallParticle.MaxStartScale = .1f;

            fireSmallParticle.MinEndScale = .2f;
            fireSmallParticle.MaxEndScale = .2f;

            fireSmallParticle.BlendState       = BlendState.Additive;
            fireSmallParticle.alphaDecay       = .05f;
            fireSmallParticle.alphaDecayLength = .1f;

            particleSystemInfoDict["fireSmall"] = fireSmallParticle;
        }
Пример #4
0
        public void AddFireSmallInfo()
        {
            ParticleSystemInfo fireSmallParticle = new ParticleSystemInfo();
            fireSmallParticle.TextureName = "fire";
            fireSmallParticle.name = "fireSmall";
            fireSmallParticle.maxParticles = 40;
            fireSmallParticle.minParticles = 20;

            fireSmallParticle.minLife = 0f;
            fireSmallParticle.maxLife = .1f;

            fireSmallParticle.minVelocity = new Vector2(-10, -10);
            fireSmallParticle.maxVelocity = new Vector2(10, 10);

            fireSmallParticle.minAcceleration = new Vector2(0, 0);
            fireSmallParticle.maxAcceleration = new Vector2(0, 0);

            fireSmallParticle.minRotation = 0;
            fireSmallParticle.maxRotation = 2* (float) Math.PI;

            // Set gravity upside down, so the flames will 'fall' upward.
            fireSmallParticle.Gravity = new Vector2(0, 0);

            fireSmallParticle.MinColor = new Color(0, 0, 0, 255);
            fireSmallParticle.MaxColor = new Color(255, 255, 255, 255);

            fireSmallParticle.MinStartScale = .1f;
            fireSmallParticle.MaxStartScale = .1f;

            fireSmallParticle.MinEndScale = .2f;
            fireSmallParticle.MaxEndScale = .2f;

            fireSmallParticle.BlendState = BlendState.Additive;
            fireSmallParticle.alphaDecay = .05f;
            fireSmallParticle.alphaDecayLength = .1f;

            particleSystemInfoDict["fireSmall"] = fireSmallParticle;
        }
Пример #5
0
        public void AddFireworkInfo()
        {
            ParticleSystemInfo fireworkParticle = new ParticleSystemInfo();

            fireworkParticle.TextureName  = "fire";
            fireworkParticle.name         = "firework";
            fireworkParticle.maxParticles = 200;
            fireworkParticle.minParticles = 100;

            fireworkParticle.minLife = 1f;
            fireworkParticle.maxLife = 1.5f;

            fireworkParticle.minVelocity = new Vector2(-50, -50);
            fireworkParticle.maxVelocity = new Vector2(50, 50);

            fireworkParticle.minAcceleration = new Vector2(0, 0);
            fireworkParticle.maxAcceleration = new Vector2(0, 0);

            fireworkParticle.Gravity = new Vector2(0, 0);

            fireworkParticle.MinColor = new Color(0, 0, 0, 0);
            fireworkParticle.MaxColor = new Color(255, 255, 255, 255);

            fireworkParticle.MinStartScale = .02f;
            fireworkParticle.MaxStartScale = .02f;

            fireworkParticle.MinEndScale = .03f;
            fireworkParticle.MaxEndScale = .03f;

            fireworkParticle.BlendState       = BlendState.AlphaBlend;
            fireworkParticle.alphaDecay       = 0;
            fireworkParticle.alphaDecayLength = 0;
            fireworkParticle.minRotation      = (float)Math.PI * .1f;
            fireworkParticle.maxRotation      = (float)Math.PI * .1f;

            particleSystemInfoDict["firework"] = fireworkParticle;
        }
Пример #6
0
        public void AddSparkInfo()
        {
            ParticleSystemInfo sparkParticle = new ParticleSystemInfo();

            sparkParticle.TextureName  = "fire";
            sparkParticle.name         = "spark";
            sparkParticle.maxParticles = 100;
            sparkParticle.minParticles = 50;

            sparkParticle.minLife = 0f;
            sparkParticle.maxLife = .1f;

            sparkParticle.minVelocity = new Vector2(-30, -30);
            sparkParticle.maxVelocity = new Vector2(30, 30);

            sparkParticle.minAcceleration = new Vector2(10, 10);
            sparkParticle.maxAcceleration = new Vector2(10, 10);

            // Set gravity upside down, so the flames will 'fall' upward.
            sparkParticle.Gravity = new Vector2(0, 10);

            sparkParticle.MinColor = new Color(255, 0, 0, 200);
            sparkParticle.MaxColor = new Color(255, 0, 0, 200);

            sparkParticle.MinStartScale = 1f;
            sparkParticle.MaxStartScale = 1;

            sparkParticle.MinEndScale = 2;
            sparkParticle.MaxEndScale = 2;

            sparkParticle.BlendState       = BlendState.Additive;
            sparkParticle.alphaDecay       = .05f;
            sparkParticle.alphaDecayLength = .1f;

            particleSystemInfoDict["spark"] = sparkParticle;
        }
Пример #7
0
        public void AddSmokeInfo()
        {
            ParticleSystemInfo smokeParticle = new ParticleSystemInfo();

            smokeParticle.TextureName  = "smoke";
            smokeParticle.name         = "smoke";
            smokeParticle.maxParticles = 600;
            smokeParticle.minParticles = 400;

            smokeParticle.minLife = 1;
            smokeParticle.maxLife = 3;

            smokeParticle.minVelocity = new Vector2(-10, 10);
            smokeParticle.maxVelocity = new Vector2(10, 50);

            smokeParticle.minAcceleration = new Vector2(-10, 10);
            smokeParticle.maxAcceleration = new Vector2(10, 50);

            // Set gravity upside down, so the flames will 'fall' upward.
            smokeParticle.Gravity = new Vector2(0, 15);

            smokeParticle.MinColor = new Color(100, 100, 100, 100);
            smokeParticle.MaxColor = new Color(100, 100, 100, 100);

            smokeParticle.MinStartScale = 3;
            smokeParticle.MaxStartScale = 5;

            smokeParticle.MinEndScale = 6;
            smokeParticle.MaxEndScale = 9;

            smokeParticle.BlendState       = BlendState.AlphaBlend;
            smokeParticle.alphaDecay       = .01f;
            smokeParticle.alphaDecayLength = 1f;

            particleSystemInfoDict["smoke"] = smokeParticle;
        }
Пример #8
0
        public void AddFireworkInfo()
        {
            ParticleSystemInfo fireworkParticle = new ParticleSystemInfo();
            fireworkParticle.TextureName = "fire";
            fireworkParticle.name = "firework";
            fireworkParticle.maxParticles = 200;
            fireworkParticle.minParticles = 100;

            fireworkParticle.minLife = 1f;
            fireworkParticle.maxLife = 1.5f;

            fireworkParticle.minVelocity = new Vector2(-50, -50);
            fireworkParticle.maxVelocity = new Vector2(50, 50);

            fireworkParticle.minAcceleration = new Vector2(0, 0);
            fireworkParticle.maxAcceleration = new Vector2(0, 0);

            fireworkParticle.Gravity = new Vector2(0, 0);

            fireworkParticle.MinColor = new Color(0, 0, 0, 0);
            fireworkParticle.MaxColor = new Color(255, 255, 255, 255);

            fireworkParticle.MinStartScale = .02f;
            fireworkParticle.MaxStartScale = .02f;

            fireworkParticle.MinEndScale = .03f;
            fireworkParticle.MaxEndScale = .03f;

            fireworkParticle.BlendState = BlendState.AlphaBlend;
            fireworkParticle.alphaDecay = 0;
            fireworkParticle.alphaDecayLength = 0;
            fireworkParticle.minRotation = (float)Math.PI * .1f;
            fireworkParticle.maxRotation = (float)Math.PI * .1f;

            particleSystemInfoDict["firework"] = fireworkParticle;
        }
Пример #9
0
 //0 lifetime = infinity
 public ParticleSystem Spawn(ParticleSystemInfo psInfo, Vector2 origin, float lifetime = 0)
 {
     ParticleSystem temp = freeParticleSystems.Dequeue();
     temp.Initialize(psInfo, origin, lifetime);
     temp.LoadContent(contentManager, device);
     particleSystems.Add(temp);
     return temp;
 }
Пример #10
0
        public void AddSparkInfo()
        {
            ParticleSystemInfo sparkParticle = new ParticleSystemInfo();
            sparkParticle.TextureName = "fire";
            sparkParticle.name = "spark";
            sparkParticle.maxParticles = 100;
            sparkParticle.minParticles = 50;

            sparkParticle.minLife = 0f;
            sparkParticle.maxLife = .1f;

            sparkParticle.minVelocity = new Vector2(-30, -30);
            sparkParticle.maxVelocity = new Vector2(30, 30);

            sparkParticle.minAcceleration = new Vector2(10, 10);
            sparkParticle.maxAcceleration = new Vector2(10, 10);

            // Set gravity upside down, so the flames will 'fall' upward.
            sparkParticle.Gravity = new Vector2(0, 10);

            sparkParticle.MinColor = new Color(255, 0, 0, 200);
            sparkParticle.MaxColor = new Color(255, 0, 0, 200);

            sparkParticle.MinStartScale = 1f;
            sparkParticle.MaxStartScale = 1;

            sparkParticle.MinEndScale = 2;
            sparkParticle.MaxEndScale = 2;

            sparkParticle.BlendState = BlendState.Additive;
            sparkParticle.alphaDecay = .05f;
            sparkParticle.alphaDecayLength = .1f;

            particleSystemInfoDict["spark"] = sparkParticle;
        }
Пример #11
0
        public void AddSmokeInfo()
        {
            ParticleSystemInfo smokeParticle = new ParticleSystemInfo();
            smokeParticle.TextureName = "smoke";
            smokeParticle.name = "smoke";
            smokeParticle.maxParticles = 600;
            smokeParticle.minParticles = 400;

            smokeParticle.minLife = 1;
            smokeParticle.maxLife = 3;

            smokeParticle.minVelocity = new Vector2(-10, 10);
            smokeParticle.maxVelocity = new Vector2(10, 50);

            smokeParticle.minAcceleration = new Vector2(-10, 10);
            smokeParticle.maxAcceleration = new Vector2(10, 50);

            // Set gravity upside down, so the flames will 'fall' upward.
            smokeParticle.Gravity = new Vector2(0, 15);

            smokeParticle.MinColor = new Color(100, 100, 100, 100);
            smokeParticle.MaxColor = new Color(100, 100, 100, 100);

            smokeParticle.MinStartScale = 3;
            smokeParticle.MaxStartScale = 5;

            smokeParticle.MinEndScale = 6;
            smokeParticle.MaxEndScale = 9;

            smokeParticle.BlendState = BlendState.AlphaBlend;
            smokeParticle.alphaDecay = .01f;
            smokeParticle.alphaDecayLength = 1f;

            particleSystemInfoDict["smoke"] = smokeParticle;
        }
Пример #12
0
 public void Initialize(ParticleSystemInfo particleInfo, Vector2 origin, float lifetime)
 {
     for (var i = particles.Count - 1; i > 0; i--)
     {
         particles[i].isAlive = false;
     }
     status = ParticleStatus.Alive;
     this.particleInfo = particleInfo;
     this.origin = origin;
     makeParticles();
     this.lifetime = lifetime;
     this.time_elapsed = 0;
 }