Esempio n. 1
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);
        }
Esempio n. 2
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);
            }
        }