/// <summary> /// Updates the <see cref="IRefractionEffect"/>. /// </summary> /// <param name="currentTime">The current game time in milliseconds.</param> public virtual void Update(TickCount currentTime) { if (IsExpired) { return; } _lastUpdateTime = currentTime; // Get the life of the effect var totalElapsedTime = (int)currentTime - _startTime; if (totalElapsedTime < 0) { totalElapsedTime = 0; } // Check if expired if (totalElapsedTime >= _lifeSpan) { Dispose(); return; } // Update the size _size = ExpansionRate * totalElapsedTime; // Update the sprite ExplosionNoise.Update(currentTime); }
/// <summary> /// Draws the <see cref="IRefractionEffect"/>. /// </summary> /// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw with.</param> public virtual void Draw(ISpriteBatch spriteBatch) { if (IsExpired || !IsEnabled) { return; } // Update the effect's parameters SetShaderParameters(_lastUpdateTime); // Draw var dest = ToRectangle(); var oldBlendMode = spriteBatch.BlendMode; try { spriteBatch.BlendMode = BlendMode.Add; try { Shader.Bind(); ExplosionNoise.Draw(spriteBatch, dest); } finally { Shader.Unbind(); } } finally { spriteBatch.BlendMode = oldBlendMode; } }