public void Draw(SpriteBatch batch, DrawInformation information) { if (_isLight != information.DrawLights) return; Animation _current = _animations[_currentAnimation]; _size = new Vector2(_current.CurrentFrame.Width, _current.CurrentFrame.Height); if (information.Centered) _loc = information.Position - (_size / 2); else _loc = information.Position; Vector2 center = Game1.Instance.Camera.Center; Rectangle bounds = Game1.Instance.Window.ClientBounds; // Invulnerable counter configuration if (_invulnerable != information.Invulnerable) { _invulnerable = information.Invulnerable; if (!_invulnerable) _blinkTime = 0; } // Set color according to invulnerable and counter state Color color; if (_invulnerable && _blinkTime < _blinkDuration / 2.0) color = Color.Red; // Red in the first half of the counter else color = Color.White; // White in the second half or when not invulnerable batch.Draw(_spriteSheet, new Rectangle((int)_loc.X - (int)center.X + (int)Math.Round(bounds.Width / 2.0f), (int)_loc.Y - (int)center.Y + (int)Math.Round(bounds.Height / 2.0f), (int)_size.X, (int)_size.Y), _current.CurrentFrame, color, information.Rotation, _size / 2, SpriteEffects.None, 0.5f); }
public void Draw(SpriteBatch batch, DrawInformation information) { // TODO That's 90% the same code as in StaticDrawer.Draw!! if (_isLight != information.DrawLights) return; Animation _current = _animations[_currentAnimation]; _size = new Vector2(_current.CurrentFrame.Width, _current.CurrentFrame.Height); Vector2 drawLocation = information.Position; Vector2 center = Game1.Instance.Camera.Center; Rectangle bounds = Game1.Instance.Window.ClientBounds; // Invulnerable counter configuration if (_flashing != information.Flashing) { _flashing = information.Flashing; if (!_flashing) _blinkTime = 0; } // Set color according to invulnerable and counter state Color color; if (_flashing && _blinkTime < _blinkDuration / 2.0) color = Color.Red; // Red in the first half of the counter else color = Color.White; // White in the second half or when not invulnerable // Draw shadow if requested if (information.Shadow) { Texture2D tex = Game1.Instance.Content.Load<Texture2D>("sprite/shadow"); batch.Draw(tex, new Rectangle( (int)drawLocation.X - (int)center.X + (int)Math.Round(bounds.Width / 2f) - (int)(_size.X / 2f), (int)drawLocation.Y - (int)center.Y + (int)Math.Round(bounds.Height / 2f) + (int)(_size.Y / 2f) - (int)(tex.Bounds.Height / 2f) - 24, tex.Bounds.Width, tex.Bounds.Height), Color.White); } // Draw entity batch.Draw(_spriteSheet, Game1.Instance.Camera.GetDrawRectangle(_owner.BoundingRect, information.Altitude), _current.CurrentFrame, color, information.Rotation, _size / 2, SpriteEffects.None, 0.5f); }
public void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch batch, DrawInformation information) { _lower.Draw(batch, information); _upper.Draw(batch, information); }
public override void Draw(GameTime gameTime) { // Point drawPos = new Point((int)this.GetDrawPosition().X, (int)this.GetDrawPosition().Y); DrawInformation information = new DrawInformation() { Position = this.Position, Rotation = _rotation, Scale = this.Size, Invulnerable = this.Invulnerable, DrawLights=Game1.Instance.DrawingLights }; if (_mDrawModule != null) _mDrawModule.Draw(((Game1)Game).SpriteBatch, information); }