Exemple #1
0
        public ParticleEmitter (int particlecount)
        {
            ParticleCount = particlecount;

            Particles = new Particle[ParticleCount];

            for (int i = 0; i < ParticleCount; i++)
                Particles [i] = new Particle ();

            //updatethread = new Thread (InnerUpdate);
            //updatethread.Start ();

            time = 0.0f;
        }
        protected override void UpdateParticle (Particle par, float time)
        {
            if (par.Life >= 0.05f) 
            {
                if ((par.Position - SpawnPosition).Length > 9.05f) {
                    par.Color = new FreezingArcher.Math.Color4 (par.Color.R, par.Color.G, par.Color.B, (1 - (par.Age / par.LifeTime)));

                    par.Velocity = Math.Vector3.Zero;
                    par.Update (time);
                } else if ((par.Position - SpawnPosition).Length > 2.05f) {
                    if (par.Color.A < (1 - (par.Age / par.LifeTime)))
                        par.Color = new FreezingArcher.Math.Color4 (par.Color.R, par.Color.G, par.Color.B, par.Color.A + time * 0.3f);
                    else
                        par.Color = new FreezingArcher.Math.Color4 (par.Color.R, par.Color.G, par.Color.B, (1 - (par.Age / par.LifeTime)));

                    FreezingArcher.Math.Vector3 actual = par.Velocity;
                    par.Velocity = actual;
                    par.Update (time);
                } else 
                {
                    par.Color = new FreezingArcher.Math.Color4 (par.Color.R, par.Color.G, par.Color.B, par.Color.A - time * 0.02f);
                    FreezingArcher.Math.Vector3 actual = par.Velocity;
                    par.Velocity = actual;
                    par.Update (time);
                }

            } else
            {
                par.Reset ();

                float invert1 = Convert.ToBoolean (rnd.Next (0, 2)) ? -1 : 1;
                float invert2 = Convert.ToBoolean (rnd.Next (0, 2)) ? -1 : 1;

                par.Position = SpawnPosition + (new FreezingArcher.Math.Vector3 ((float)rnd.NextDouble () * 0.05f * invert1, 0.0f, 
                    (float)rnd.NextDouble () * 0.05f * invert2));

                par.Velocity = (new FreezingArcher.Math.Vector3 ((float)rnd.NextDouble () * 0.7f * invert1, 0.0f, 
                    (float)rnd.NextDouble () * 0.7f * invert2));

                par.Mass = 1.0f;
                par.Size = new FreezingArcher.Math.Vector2(1.3f, 0.7f);
                par.Color = new FreezingArcher.Math.Color4(0.4f, 0.4f , 0.0f, 0.01f);
                par.Life = 1.2f;
                par.LifeTime = 20.0f * (float)rnd.NextDouble();
            }
        }
        protected override void UpdateParticle (Particle par, float time)
        {
            if (par.Life >= 0.05f) 
            {
                if ((par.Position - SpawnPosition).Length > 0.7f)
                {
                    par.Color = new FreezingArcher.Math.Color4(par.Color.R, par.Color.G, par.Color.B, par.Color.A - time * 0.40f);

                    par.Velocity = Math.Vector3.Zero;
                    par.Update (time);
                } else 
                {
                    //par.Life -= time * 4.0f;

                    if (par.Color.A < 0.7f)
                        par.Color = new FreezingArcher.Math.Color4 (par.Color.R, par.Color.G, par.Color.B, par.Color.A + time * 0.80f);

                    FreezingArcher.Math.Vector3 actual = par.Velocity;
                    par.Velocity = actual;
                    par.Update (time);
                }
                    
            } else
            {
                par.Reset ();

                float invert1 = Convert.ToBoolean (rnd.Next (0, 2)) ? -1 : 1;
                float invert2 = Convert.ToBoolean (rnd.Next (0, 2)) ? -1 : 1;
                float invert3 = Convert.ToBoolean (rnd.Next (0, 2)) ? -1 : 1;

                par.Position = SpawnPosition + (new FreezingArcher.Math.Vector3 ((float)rnd.NextDouble () * 0.2f * invert1, (float)rnd.NextDouble () * 0.2f * invert2, 
                    (float)rnd.NextDouble () * 0.2f * invert3));
                
                par.Velocity = (new FreezingArcher.Math.Vector3 ((float)rnd.NextDouble () * 0.4f * invert1, (float)rnd.NextDouble () * 0.4f * invert2, 
                    (float)rnd.NextDouble () * 0.4f * invert3));
                
                par.Life = 0.7f;
                par.LifeTime = 1.0f * (float)rnd.NextDouble();
                par.Size = new FreezingArcher.Math.Vector2(1.2f, 1.2f);
                par.Color = new FreezingArcher.Math.Color4(0.6f, 1.0f , 0.6f, 0.3f);
            }
        }
        protected override void UpdateParticle (Particle par, float time)
        {
            if (par.Life >= 0.05f)
            {
                if (par.Position.Y > 10.0f)
                {
                    par.Color = new Color4 (par.Color.R, par.Color.G, par.Color.B, (1.0f - ((float)par.Age / (float)par.LifeTime) * 0.1f));
                    
                    par.Velocity = Math.Vector3.Zero;
                    par.Update (time);
                }
                else
                {
                    if (par.Color.A < 0.7f)
                        par.Color = new Color4 (par.Color.R, par.Color.G, par.Color.B, par.Color.A + time * 0.8f);

                    FreezingArcher.Math.Vector3 actual = par.Velocity;
                    par.Velocity = actual;

                    par.Update (time);
                }
            }
            else
            {
                par.Reset ();

                float invert1 = Convert.ToBoolean (rnd.Next (0, 2)) ? -1 : 1;
                float invert2 = Convert.ToBoolean (rnd.Next (0, 2)) ? -1 : 1;

                par.Position = (new FreezingArcher.Math.Vector3 ((float)rnd.NextDouble () * 3f * invert1, 0.0f, 
                    (float)rnd.NextDouble () * 3f * invert2)) + SpawnPosition;

                par.Velocity = new FreezingArcher.Math.Vector3 (0.0f, (float)rnd.NextDouble () * 5f, 0);
                par.Mass = 1.0f;
                par.Size = new Vector2(0.5f, 0.5f);
                par.Color = new FreezingArcher.Math.Color4(0.4f, 0.4f , 0.4f, 1f);
                par.Life = 1.2f;
                par.LifeTime = 3.0f * (float)rnd.NextDouble();
            }
        }
Exemple #5
0
        protected override void UpdateParticle (Particle par, float time)
        {
            par.Velocity = Vector3.Zero;
            par.Position -= cachedSpawnPoint;
            par.Position += SpawnPosition;

            if (par.Life >= 0.05f) 
            {
                if ((par.Position - SpawnPosition).Length > 0.05f)
                {
                    par.Velocity = Math.Vector3.Zero;
                    par.Update (time);
                } else 
                {
                    FreezingArcher.Math.Vector3 actual = par.Velocity;
                    par.Velocity = actual;
                    par.Update (time);
                }

            } else
            {
                par.Reset ();

                float invert1 = Convert.ToBoolean (rnd.Next (0, 2)) ? -1 : 1;
                float invert2 = Convert.ToBoolean (rnd.Next (0, 2)) ? -1 : 1;
                float invert3 = Convert.ToBoolean (rnd.Next (0, 2)) ? -1 : 1;

                par.Position = SpawnPosition + (new FreezingArcher.Math.Vector3 ((float)rnd.NextDouble () * 0.05f * invert1, (float)rnd.NextDouble () * 0.05f * invert2, 
                    (float)rnd.NextDouble () * 0.05f * invert3));

                par.Velocity = (new FreezingArcher.Math.Vector3 ((float)rnd.NextDouble () * 0.05f * invert1, (float)rnd.NextDouble () * 0.05f * invert2, 
                    (float)rnd.NextDouble () * 0.05f * invert3));

                par.Color = new FreezingArcher.Math.Color4(0.0f, 0.0f , 0.5f, 1f);
                par.Life = 1.2f;
                par.Mass = 1.0f;
                par.Size = new Vector2(0.3f, 0.3f);
            }
        }
Exemple #6
0
 protected abstract void UpdateParticle(Particle par, float time);