Esempio n. 1
0
        public void Birth(Particle particle)
        {
            particle.position.X = (float)(rand.NextDouble() - 0.5f) * radius[entity.curr_size];
            particle.position.Y = (float)(rand.NextDouble() - 0.5f) * radius[entity.curr_size];
            particle.position.Z = (float)(rand.NextDouble() - 0.5f) * radius[entity.curr_size];
            particle.position.X += entity.position.X;
            particle.position.Y += entity.position.Y;
            particle.position.Z += entity.position.Z;

            particle.region = Resources.bubble_texture_region;
            particle.scale = new Vector2(particle.region.width * (1f / particle.region.texture.Width), particle.region.height * (1f / particle.region.texture.Height));
            particle.scale *= (float)(rand.NextDouble()) * scale[entity.curr_size];
            particle.color.A = 0;
        }
Esempio n. 2
0
        public ParticleManager()
        {
            particle_array = new Particle[NUM_PARTICLES];
            particle_pool = new Queue<Particle>(NUM_PARTICLES);

            for (int i = 0; i < particle_array.Length; i++)
            {
                Particle particle = new Particle();
                particle_array[i] = particle;
                particle_pool.Enqueue(particle);
                particle.in_pool = true;
                particle.is_alive = false;
            }
        }
Esempio n. 3
0
        public void Add(Particle particle)
        {
            TextureRegion region = particle.region;
            ParticleInfo particleinfo = new ParticleInfo(region, particle.color, ref particle.world);

            if (!particles.ContainsKey(region.texture))
                particles[region.texture] = new List<ParticleInfo>();
            particles[region.texture].Add(particleinfo);
        }
Esempio n. 4
0
        public void Frame(Particle particle, double elapsed)
        {
            float fade = 1 - particle.age / particle.life;
            fade = fade * 0.3f;
            particle.color.A = (byte)(byte.MaxValue * fade);

            particle.velocity.X = MathHelper.Lerp(particle.velocity.X, (float)(rand.NextDouble() - 0.5f), 0.0005f);
            particle.velocity.Y = MathHelper.Lerp(particle.velocity.Y, (float)(rand.NextDouble() - 0.5f), 0.0005f);
            particle.velocity.Z = MathHelper.Lerp(particle.velocity.Z, (float)(rand.NextDouble() - 0.5f), 0.0005f);
        }
Esempio n. 5
0
        public void Tail(Particle parent)
        {
            ParticleManager particlemanager = ParticleManager.GetInstance();
            Particle child = particlemanager.Emit(tail_logic, (float)rand.NextDouble());

            if (child == null)
                return;

            child.scale = parent.scale;
            child.position = parent.position;
        }
Esempio n. 6
0
        public void Frame(Particle particle, double elapsed)
        {
            time += (float)elapsed;
            if (time > 0.1f)
            {
                Tail(particle);
                time = 0;
            }

            float alpha = particle.age / particle.life;
            alpha = (float)Math.Sin(alpha * MathHelper.Pi);
            particle.color.A = (byte)(byte.MaxValue * alpha);

            particle.velocity.X = MathHelper.Lerp(particle.velocity.X, (float)(rand.NextDouble() - 0.5f), 0.003f);
            particle.velocity.Y = MathHelper.Lerp(particle.velocity.Y, (float)(rand.NextDouble() - 0.5f), 0.003f);
            particle.velocity.Z = MathHelper.Lerp(particle.velocity.Z, (float)(rand.NextDouble() - 0.5f), 0.003f);
        }
Esempio n. 7
0
 public void Death(Particle particle)
 {
     Emit();
 }
Esempio n. 8
0
 public void Frame(Particle particle, double elapsed)
 {
     float alpha = 1 - particle.age / particle.life;
     particle.color.A = (byte)(byte.MaxValue * alpha);
 }
Esempio n. 9
0
 public void Death(Particle particle)
 {
 }
Esempio n. 10
0
 public void Birth(Particle particle)
 {
     particle.region = Resources.particle_texture_region;
     particle.scale = new Vector2(particle.region.width * (1f / particle.region.texture.Width), particle.region.height * (1f / particle.region.texture.Height));
 }
Esempio n. 11
0
 public void Death(Particle particle)
 {
     count--;
 }
Esempio n. 12
0
        public void Frame(Particle particle, double elapsed)
        {
            float alpha = particle.age / particle.life;
            alpha = (float)Math.Sin(alpha*MathHelper.Pi);
            particle.color.A = (byte)(byte.MaxValue * alpha);

            particle.velocity.X = MathHelper.Lerp(particle.velocity.X, (float)(rand.NextDouble() - 0.5f), 0.001f);
            particle.velocity.Y = MathHelper.Lerp(particle.velocity.Y, (float)(rand.NextDouble() - 0.5f), 0.001f);
            particle.velocity.Z = MathHelper.Lerp(particle.velocity.Z, (float)(rand.NextDouble() - 0.5f), 0.001f);

            float distance;
            Vector3.Distance(ref particle.position, ref entity.position, out distance);
            if (distance < 1)
            {
                float amount = 0.0002f;
                particle.velocity.X = MathHelper.Lerp(particle.velocity.X, entity.velocity.X, amount);
                particle.velocity.Y = MathHelper.Lerp(particle.velocity.Y, entity.velocity.Y, amount);
            }
        }
Esempio n. 13
0
        public void Frame(Particle particle, double elapsed)
        {
            float alpha = particle.age / particle.life;
            alpha = (float)Math.Sin(alpha * MathHelper.Pi) * 0.15f;
            particle.color.A = (byte)(byte.MaxValue * alpha);

            particle.velocity.X = MathHelper.Lerp(particle.velocity.X, (float)(rand.NextDouble() - 0.5f), 0.001f);
            particle.velocity.Y = MathHelper.Lerp(particle.velocity.Y, (float)(rand.NextDouble() - 0.5f), 0.001f);
            particle.velocity.Z = MathHelper.Lerp(particle.velocity.Z, (float)(rand.NextDouble() - 0.5f), 0.001f);
        }