public void Draw(SpriteBatch spriteBatch, Vector2 offset) { Rectangle sourceRectangle = new Rectangle(0, 0, Texture.Width, Texture.Height); Vector2 origin = new Vector2(Texture.Width / 2, Texture.Height / 2); Color color = OrionMath.LinearInterpolate(EndColor, StartColor, Life / _maxLife); spriteBatch.Draw(Texture, offset + Position, sourceRectangle, new Color(color, Alpha), Angle, origin, Size, SpriteEffects.None, 0f); }
public TValue GetNextValue() { TValue random = default(TValue); if (typeof(TValue) == typeof(int)) { int a = (int)Convert.ChangeType(UpperBound, typeof(int)); int b = (int)Convert.ChangeType(LowerBound, typeof(int)); double rand = _Randomizer.NextDouble(); int val = OrionMath.LinearInterpolate(a, b, rand); random = (TValue)Convert.ChangeType(val, typeof(TValue)); } else if (typeof(TValue) == typeof(float)) { float a = (float)Convert.ChangeType(UpperBound, typeof(float)); float b = (float)Convert.ChangeType(LowerBound, typeof(float)); double rand = _Randomizer.NextDouble(); float val = OrionMath.LinearInterpolate(a, b, rand); random = (TValue)Convert.ChangeType(val, typeof(TValue)); } else if (typeof(TValue) == typeof(double)) { double a = (double)Convert.ChangeType(UpperBound, typeof(double)); double b = (double)Convert.ChangeType(LowerBound, typeof(double)); double rand = _Randomizer.NextDouble(); double val = OrionMath.LinearInterpolate(a, b, rand); random = (TValue)Convert.ChangeType(val, typeof(TValue)); } else if (typeof(TValue) == typeof(Vector2)) { Vector2 a = (Vector2)Convert.ChangeType(UpperBound, typeof(Vector2)); Vector2 b = (Vector2)Convert.ChangeType(LowerBound, typeof(Vector2)); double rand = _Randomizer.NextDouble(); Vector2 val = OrionMath.LinearInterpolate(a, b, rand); random = (TValue)Convert.ChangeType(val, typeof(TValue)); } else if (typeof(TValue) == typeof(Color)) { Color a = (Color)Convert.ChangeType(UpperBound, typeof(Color)); Color b = (Color)Convert.ChangeType(LowerBound, typeof(Color)); double rand = _Randomizer.NextDouble(); Color val = OrionMath.LinearInterpolate(a, b, rand); random = (TValue)Convert.ChangeType(val, typeof(TValue)); } return(random); }
public void Update(GameTime gameTime) { if (Alive) { if (Life > 0) { Life -= gameTime.ElapsedGameTime.Milliseconds; Vector2 vel = OrionMath.LinearInterpolate(EndVelocity, StartVelocity, Life / _maxLife); Position += vel * (float)gameTime.ElapsedGameTime.TotalSeconds; Angle += AngularVelocity * (float)gameTime.ElapsedGameTime.TotalSeconds; } else { Alive = false; } } }