public RainParticleEffectFactory(RainParticleEffectType rainParticleEffectType, Vector2 emitterLocation,
                                         int emitterRadius, Vector2 baseScreenSize, float maxVelX = -400, float maxVelY = 800, float rot = (float)Math.PI / 4)
        {
            random = new Random();
            this.rainParticleEffectType = rainParticleEffectType;
            this.EmitterLocation        = emitterLocation;
            this.emitterRadius          = emitterRadius;

            this.baseScreenSize = baseScreenSize;

            BaseParticleParams = new ParticleParameters
            {
                Vel = new Vector2(maxVelX, maxVelY),
                Rot = rot
            };


            switch (rainParticleEffectType)
            {
            case RainParticleEffectType.Default:
                InitDefaultRainParticle();
                break;

            default:
                InitDefaultRainParticle();
                break;
            }
        }
        public FootstepParticleEffectFactory(Vector2 emitterLocation, int emitterRadius, int maxTTL, Vector2 maxVel, Vector2 maxAcc,
                                             float initScale, float scaleVel, Color initColor, Color finalColor, int colFadeTime,
                                             float velDamp = 1f, float initRot = 0f, float rotVel = 0f, float rotDamp = 1f, float scaleAcc = 0f, float scaleMax = 1, byte finalColAlpha = 0)
        {
            random = new Random();
            this.EmitterLocation = emitterLocation;
            this.emitterRadius   = emitterRadius;

            BaseParticleParams = new ParticleParameters
            {
                TTL         = maxTTL,
                Vel         = maxVel,
                Acc         = maxAcc,
                VelDamp     = velDamp,
                Rot         = initRot,
                RotVel      = rotVel,
                RotDamp     = rotDamp,
                Scale       = initScale,
                ScaleVel    = scaleVel,
                ScaleAcc    = scaleAcc,
                ScaleMax    = scaleMax,
                InitCol     = initColor,
                FinalCol    = finalColor,
                ColFadeTime = colFadeTime
            };

            //set alpha value of the colors
            BaseParticleParams.SetFinalColorAlpha(finalColAlpha);
        }
        private void InitParticleFromBase()
        {
            ParticleParams = new ParticleParameters
            {
                VelDamp  = BaseParticleParams.VelDamp,
                Rot      = BaseParticleParams.Rot,
                RotVel   = BaseParticleParams.RotVel,
                RotDamp  = BaseParticleParams.RotDamp,
                Scale    = BaseParticleParams.Scale,
                ScaleAcc = BaseParticleParams.ScaleAcc,
                ScaleMax = BaseParticleParams.ScaleMax,
                InitCol  = BaseParticleParams.InitCol,
                FinalCol = BaseParticleParams.FinalCol
            };

            ParticleParams.SetInitColorAlpha(BaseParticleParams.InitCol.A);
            ParticleParams.SetFinalColorAlpha(BaseParticleParams.FinalCol.A);
        }
예제 #4
0
        public override void Update(GameTime gameTime)
        {
            //Create new particles if not paused
            if (!Paused)
            {
                EffectDuration   -= gameTime.ElapsedGameTime.Milliseconds;
                burstCountDownMs -= gameTime.ElapsedGameTime.Milliseconds;

                if (burstCountDownMs <= 0 && (EffectDuration >= 0 || Continuous))
                {
                    for (int i = 0; i < newParticleAmount; i++)
                    {
                        ParticleParams = particleEffectFactory.CreateParticleEffect();
                        if (CurrentSprites.Count == 1)
                        {
                            particles.Add(new Particle(CurrentSprites[0], ParticleParams));
                        }
                        else
                        {
                            int pos = Random.Next(CurrentSprites.Count);
                            particles.Add(new Particle(CurrentSprites[pos], ParticleParams));
                        }
                    }

                    burstCountDownMs = burstFrequencyMs;

                    newParticleAmount += newParticleAmountDelta;
                }
            }

            //We move through the list backwards, so that particles are removed at the correct order
            for (int i = particles.Count - 1; i >= 0; i--)
            {
                particles[i].Update(gameTime);

                if (particles[i].ParticleParams.TTL <= 0 || particles[i].ParticleParams.Scale <= 0 || (baseScreenSize.Y > 0 && particles[i].ParticleParams.Pos.Y > baseScreenSize.Y))
                {
                    particles.RemoveAt(i);
                }
            }
        }
        private void InitParticleFromBase()
        {
            ParticleParams = new ParticleParameters
            {
                TTL         = BaseParticleParams.TTL,
                Vel         = BaseParticleParams.Vel,
                Acc         = BaseParticleParams.Acc,
                VelDamp     = BaseParticleParams.VelDamp,
                RotVel      = BaseParticleParams.RotVel,
                RotDamp     = BaseParticleParams.RotDamp,
                Scale       = BaseParticleParams.Scale,
                ScaleAcc    = BaseParticleParams.ScaleAcc,
                ScaleMax    = BaseParticleParams.ScaleMax,
                InitCol     = BaseParticleParams.InitCol,
                FinalCol    = BaseParticleParams.FinalCol,
                ColFadeTime = BaseParticleParams.ColFadeTime
            };

            ParticleParams.SetInitColorAlpha(BaseParticleParams.InitCol.A);
            ParticleParams.SetFinalColorAlpha(BaseParticleParams.FinalCol.A);
        }
        public FireParticleEffectFactory(FireParticleEffectType fireParticleEffectType, Vector2 emitterLocation,
                                         int emitterRadius)
        {
            random = new Random();
            this.fireParticleEffectType = fireParticleEffectType;
            this.EmitterLocation        = emitterLocation;
            this.emitterRadius          = emitterRadius;

            BaseParticleParams = new ParticleParameters();

            switch (fireParticleEffectType)
            {
            case  FireParticleEffectType.Default:
                InitDefaultFireParticle();
                break;

            default:
                InitDefaultFireParticle();
                break;
            }
        }
        public FogParticleEffectFactory(FogParticleEffectType fogParticleEffectType, Vector2 emitterLocation,
                                        int emitterRadius, int duration)
        {
            random = new Random();
            this.fogParticleEffectType = fogParticleEffectType;
            this.EmitterLocation       = emitterLocation;
            this.emitterRadius         = emitterRadius;
            this.duration = duration;

            BaseParticleParams = new ParticleParameters();

            switch (fogParticleEffectType)
            {
            case FogParticleEffectType.Default:
                InitDefaultFogParticle();
                break;

            default:
                InitDefaultFogParticle();
                break;
            }
        }
예제 #8
0
 public Particle(RenderObject rep, ParticleParameters particleParams) : base(rep)
 {
     ParticleParams = particleParams;
     currentSprite  = (Sprite)rep;
 }