예제 #1
0
 public Emitter()
 {
     particleTypes            = new List <ParticleType>();
     shape                    = new EmitterShape(EmitterShapeType.Point);
     emissionAngle            = new LinearProperty(0, "Emission Angle", 0, 360);
     emissionRange            = new LinearProperty(360, "Emission Range", 0, 360);
     globalOpacityModifier    = new LinearProperty(1, "Global Opacity Modifier", 0, 1);
     _attractorEnabled        = false;
     _attractorForce          = 2f;
     _attractorPositionOffset = new Vector2(0, 0);
     _isStopped               = false;
     _isPaused                = false;
 }
예제 #2
0
 public void Update(float elapsed, float lerpLife, EmitterShape emitterShape, float opacityModifier, float emitterEmissionAngle, float emitterEmissionRange)
 {
     // if we are starting for the first time in this lifespan
     if (lerpLife == 0)
     {
         _singleParticleEmitted = false;
     }
     this._emitterEmissionAngle = emitterEmissionAngle;
     this._emitterEmissionRange = emitterEmissionRange;
     if (_parent.IsStopped == false)
     {
         if (_useSingleParticle == true)
         {
             if (_singleParticleEmitted == false)
             {
                 SpawnParticle(lerpLife, emitterShape.GetNewEmissionPoint());
                 _singleParticleEmitted = true;
             }
         }
         else
         {
             float _newQuantity = Particle.GetLerpValueWithVariation(_quantity.Values, _quantityVariation.Values, lerpLife);
             _newQuantity = _newQuantity / 60.0f;
             _emissionTimerAccumulator += _newQuantity;
             while (_emissionTimerAccumulator >= 1)
             {
                 SpawnParticle(lerpLife, emitterShape.GetNewEmissionPoint());
                 _emissionTimerAccumulator -= 1;
             }
         }
     }
     for (int i = 0; i < _particles.Count; i++)
     {
         if (_particles[i].IsActive)
         {
             _particles[i].Update(elapsed, opacityModifier);
             // if it's dead now
             if (_particles[i].IsActive == false)
             {
                 // add it to the recycling queue
                 _freeParticles.Enqueue(_particles[i]);
             }
         }
     }
 }
예제 #3
0
 private void toolStripButtonViewShape_Click(object sender, EventArgs e)
 {
     ShapeSelection shapeSelection = new ShapeSelection();
     EmitterShape currentShape = particleEffectControl.ParticleEffect.Emitter.Shape;
     shapeSelection.ShapeType = currentShape.Type;
     shapeSelection.ShapeOffset = currentShape.Offset;
     shapeSelection.ShapeSize = currentShape.Size;
     shapeSelection.TexturePath = lastTextureMaskPath;
     if (shapeSelection.ShowDialog() == DialogResult.OK)
     {
         EmitterShape shape = new EmitterShape(shapeSelection.ShapeType, shapeSelection.ShapeSize,
             particleEffectControl.ParticleEffect.Position, shapeSelection.ShapeOffset);
         // if it's a mask, construct it
         if (shape.Type == EmitterShapeType.TextureMask)
         {
             try
             {
                 lastTextureMaskPath = shapeSelection.TexturePath;
                 Texture2D maskTexture = Texture2D.FromFile(DrawingManager.GraphicsDevice, shapeSelection.TexturePath);
                 shape.CreateTextureMaskFromTexture2D(maskTexture, shapeSelection.UseFilled, shapeSelection.UseLeft,
                     shapeSelection.UseRight, shapeSelection.UseTop, shapeSelection.UseBottom);
             }
             catch
             {
                 MessageBox.Show("Error: " + e.ToString(), "Error while loading texture", 
                     MessageBoxButtons.OK, MessageBoxIcon.Error);                        
             }
         }
         shape.Initialize();
         particleEffectControl.ParticleEffect.Emitter.Shape = shape;
     }            
 }
예제 #4
0
 public Emitter()
 {
     particleTypes = new List<ParticleType>();
     shape = new EmitterShape(EmitterShapeType.Point);
     emissionAngle = new LinearProperty(0, "Emission Angle", 0, 360);
     emissionRange = new LinearProperty(360, "Emission Range", 0, 360);
     globalOpacityModifier = new LinearProperty(1, "Global Opacity Modifier", 0, 1);
     _attractorEnabled = false;
     _attractorForce = 2f;
     _attractorPositionOffset = new Vector2(0, 0);
     _isStopped = false;
     _isPaused = false;
 }
예제 #5
0
 public void Update(float elapsed, float lerpLife, EmitterShape emitterShape, float opacityModifier, float emitterEmissionAngle, float emitterEmissionRange)
 {
     // if we are starting for the first time in this lifespan
     if (lerpLife == 0)
     {
         _singleParticleEmitted = false;
     }
     this._emitterEmissionAngle = emitterEmissionAngle;
     this._emitterEmissionRange = emitterEmissionRange;
     if ( _parent.IsStopped == false)
     {
         if (_useSingleParticle == true)
         {
             if (_singleParticleEmitted == false)
             {
                 SpawnParticle(lerpLife, emitterShape.GetNewEmissionPoint());
                 _singleParticleEmitted = true;
             }
         }
         else
         {
             float _newQuantity = Particle.GetLerpValueWithVariation(_quantity.Values, _quantityVariation.Values, lerpLife);
             _newQuantity = _newQuantity / 60.0f;                    
             _emissionTimerAccumulator += _newQuantity;
             while (_emissionTimerAccumulator >= 1)
             {
                 SpawnParticle(lerpLife, emitterShape.GetNewEmissionPoint());
                 _emissionTimerAccumulator -= 1;
             }
         }
     }            
     for (int i = 0; i < _particles.Count; i++)
     {
         if (_particles[i].IsActive)
         {
             _particles[i].Update(elapsed, opacityModifier);
             // if it's dead now
             if (_particles[i].IsActive == false)
             {
                 // add it to the recycling queue
                 _freeParticles.Enqueue(_particles[i]);
             }
         }
     }
 }