public void DrawPortrait(SpriteBatch spriteBatch, Vector2 screenPos, float targetWidth) { float backgroundScale = 1; if (PortraitBackground != null) { backgroundScale = targetWidth / PortraitBackground.size.X; PortraitBackground.Draw(spriteBatch, screenPos, scale: backgroundScale); } if (Portrait != null) { // Scale down the head sprite 10% float scale = targetWidth * 0.9f / Portrait.size.X; Vector2 offset = Portrait.size * backgroundScale / 4; Portrait.Draw(spriteBatch, screenPos + offset, scale: scale, spriteEffect: SpriteEffects.FlipHorizontally); if (AttachmentSprites != null) { float depthStep = 0.000001f; foreach (var attachment in AttachmentSprites) { DrawAttachmentSprite(spriteBatch, attachment, Portrait, screenPos + offset, scale, depthStep, SpriteEffects.FlipHorizontally); depthStep += depthStep; } } } }
public void DrawPortrait(SpriteBatch spriteBatch, Vector2 screenPos, float targetWidth) { float backgroundScale = 1; if (PortraitBackground != null) { backgroundScale = targetWidth / PortraitBackground.size.X; PortraitBackground.Draw(spriteBatch, screenPos, scale: backgroundScale); } if (Portrait != null) { // Scale down the head sprite 10% float scale = targetWidth * 0.9f / Portrait.size.X; Vector2 offset = Portrait.size * backgroundScale / 4; if (Head.SheetIndex.HasValue) { Portrait.SourceRect = new Rectangle(CalculateOffset(Portrait, Head.SheetIndex.Value.ToPoint()), Portrait.SourceRect.Size); } Portrait.Draw(spriteBatch, screenPos + offset, scale: scale, spriteEffect: SpriteEffects.FlipHorizontally); if (AttachmentSprites != null) { float depthStep = 0.000001f; foreach (var attachment in AttachmentSprites) { DrawAttachmentSprite(spriteBatch, attachment, Portrait, screenPos + offset, scale, depthStep, SpriteEffects.FlipHorizontally); depthStep += depthStep; } } } }
public void DrawPortrait(SpriteBatch spriteBatch, Vector2 screenPos, Vector2 offset, float targetWidth, bool flip = false) { if (Portrait != null) { // Scale down the head sprite 10% float scale = targetWidth * 0.9f / Portrait.size.X; if (Head.SheetIndex.HasValue) { Portrait.SourceRect = new Rectangle(CalculateOffset(Portrait, Head.SheetIndex.Value.ToPoint()), Portrait.SourceRect.Size); } Portrait.Draw(spriteBatch, screenPos + offset, Color.White, Portrait.Origin, scale: scale, spriteEffect: flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None); if (AttachmentSprites != null) { float depthStep = 0.000001f; foreach (var attachment in AttachmentSprites) { DrawAttachmentSprite(spriteBatch, attachment, Portrait, screenPos + offset, scale, depthStep, flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None); depthStep += depthStep; } } } }