예제 #1
0
        // Spawns a few planets
        public void SpawnPlanets(List<Particle> List, int count)
        {
            for (int i = 0; i < count; i++)
            {
                Texture2D text = null;
                int ran = r.Next(6);
                if (ran == 0)
                {
                    text = Planet1;
                }
                else if (ran == 1)
                {
                    text = Planet2;
                }
                else if (ran == 2)
                {
                    text = Planet3;
                }
                else if (ran == 3)
                {
                    text = Planet4;
                }
                else if (ran == 4)
                {
                    text = Planet5;
                }
                else if (ran == 5)
                {
                    text = Planet6;
                }

                Vector2 pos = new Vector2(r.Next(-100, 1380), r.Next(-100, 820));

                Particle p = new Particle(text, pos);
                float xVel = (float)(r.Next(-100, 100) / 3000.0f);
                float yVel = (float)(r.Next(-100, 100) / 3000.0f);
                p.Velocity = new Vector2(xVel, yVel);
                p.Rotation = (float)(r.Next(628) / 10.0f);
                p.Scale = (float)(r.Next(50, 125) / 100.0f);
                p.PlanetParticle = true;

                List.Add(p);
            }
        }
예제 #2
0
        // Spawn a trail behind a pod
        public void SpawnTrail(int count, Texture2D texture, Vector2 Pos, float rotation, float fadePerFrame)
        {
            for (int i = 0; i < count; i++)
            {
                Particle p = null;
                if (ParticlePool.Count > 0)
                {
                    p = ParticlePool.Pop();
                    p.Reset();
                    p.Texture = texture;
                    p.Position = Pos;
                }
                else
                {
                    p = new Particle(texture, Pos);
                }
                float vel = (float)(r.Next(20) + 10) / 10.0f;
                float rotVar = (float)(r.Next(-30, 30) / 100.0f);
                p.Velocity.X = (float)(vel * Math.Cos((double)(rotation + rotVar)));
                p.Velocity.Y = (float)(vel * Math.Sin((double)(rotation + rotVar)));
                p.FadeDecrease = fadePerFrame;
                p.LightFadeParticle = true;

                TrailParticles.Add(p);
            }
        }
예제 #3
0
        // Spawns a light fade with set scale
        public void SpawnLightFade(Vector2 Pos, BulletType bt, float fadePerFrame, float newScale)
        {
            // Choose the right texture
            Texture2D texture;
            if (bt.Equals(RedBullet))
            {
                texture = RedLight;
            }
            else if (bt.Equals(BlueBullet))
            {
                texture = BlueLight;
            }
            else if (bt.Equals(GreenBullet))
            {
                texture = GreenLight;
            }
            else
            {
                texture = YellowLight;
            }
            Particle p = null;
            if (ParticlePool.Count > 0)
            {
                p = ParticlePool.Pop();
                p.Reset();
                p.Texture = texture;
                p.Position = Pos;
            }
            else
            {
                p = new Particle(texture, Pos);
            }
            p.Velocity = Vector2.Zero;
            p.LightFadeParticle = true;
            p.FadeDecrease = fadePerFrame;
            p.Scale = newScale;

            Particles.Add(p);
        }
예제 #4
0
        // Spawns a pulse
        public void SpawnPulse(int count, Vector2 pos)
        {
            float vel = 15.0f;

            // Spawns particles in a circle
            for (float i = 0; i < (MathHelper.Pi * 2); i += ((MathHelper.Pi * 2) / count))
            {
                Vector2 velocity = new Vector2(vel * (float)Math.Cos(i), vel * (float)Math.Sin(i));

                Particle p = new Particle(PulseTexture, pos);
                p.Velocity = velocity;

                PulseParticles.Add(p);
            }
        }
예제 #5
0
        // Spawn explosion
        public void SpawnExplosion(List<Particle> ParticleList, int count, Vector2 Pos, BulletType bt, int minVel, int range, float fadePerFrame)
        {
            for(int i = 0; i < count; i++)
            {
                float rotation = ((float)r.Next(628)) / 10.0f;
                float vel = ((float)r.Next(range * 10)) / 10.0f;
                vel += (float)minVel;

                Vector2 velocity = new Vector2(vel * (float)Math.Cos(rotation), vel * (float)Math.Sin(rotation));

                // Choose the right texture
                Texture2D texture;
                Color c = Color.White;
                if (bt.Equals(RedBullet))
                {
                    texture = RedExplosionParticle;
                }
                else if (bt.Equals(BlueBullet))
                {
                    texture = BlueExplosionParticle;
                }
                else if (bt.Equals(GreenBullet))
                {
                    texture = GreenExplosionParticle;
                }
                else if(bt.Equals(YellowBullet))
                {
                    texture = YellowExplosionParticle;
                }
                else
                {
                    texture = YellowGunExplosionParticle;
                }
                Particle p = null;
                if (ParticlePool.Count > 0)
                {
                    p = ParticlePool.Pop();
                    p.Reset();
                    p.Texture = texture;
                    p.Position = Pos;
                }
                else
                {
                    p = new Particle(texture, Pos);
                }
                p.color = c;
                p.Velocity = velocity;
                p.Acceleration = -(p.Velocity / 200.0f);
                p.ExplosionParticle = true;
                if (fadePerFrame == 0)
                {
                    p.RocketParticle = true;
                }
                p.FadeDecrease = fadePerFrame;

                ParticleList.Add(p);
            }
        }