public override void Draw(Camera2D camera) { var texture2D = BorderTexture; if (Game.PlayerStats.Traits.X == 32f || Game.PlayerStats.Traits.Y == 32f) { TextureOffset = Vector2.Zero; texture2D = NeoTexture; } if (BorderBottom) { camera.Draw(texture2D, new Vector2(Bounds.Right - CornerTexture.Width + TextureOffset.X, Bounds.Bottom - TextureOffset.Y), new Rectangle(0, 0, (int)(Width / TextureScale.X) - CornerTexture.Width * 2, texture2D.Height), TextureColor, MathHelper.ToRadians(180f), Vector2.Zero, TextureScale, SpriteEffects.None, 0f); } if (BorderLeft) { camera.Draw(texture2D, new Vector2(X + TextureOffset.Y, Bounds.Bottom - CornerTexture.Width - TextureOffset.X), new Rectangle(0, 0, (int)(Height / TextureScale.Y) - CornerTexture.Width * 2, texture2D.Height), TextureColor, MathHelper.ToRadians(-90f), Vector2.Zero, TextureScale, SpriteEffects.None, 0f); } if (BorderRight) { camera.Draw(texture2D, new Vector2(Bounds.Right - TextureOffset.Y, Y + CornerTexture.Width + TextureOffset.X), new Rectangle(0, 0, (int)(Height / TextureScale.Y) - CornerTexture.Width * 2, texture2D.Height), TextureColor, MathHelper.ToRadians(90f), Vector2.Zero, TextureScale, SpriteEffects.None, 0f); } if (BorderTop) { if (Rotation == 0f) { camera.Draw(texture2D, new Vector2(X + CornerTexture.Width + TextureOffset.X, Y + TextureOffset.Y), new Rectangle(0, 0, (int)(Width / TextureScale.X) - CornerTexture.Width * 2, texture2D.Height), TextureColor, MathHelper.ToRadians(Rotation), Vector2.Zero, TextureScale, SpriteEffects.None, 0f); } else { var position = CollisionMath.UpperLeftCorner(new Rectangle((int)X, (int)Y, _width, _height), Rotation, Vector2.Zero); var position2 = CollisionMath.UpperRightCorner( new Rectangle((int)X, (int)Y, _width, _height), Rotation, Vector2.Zero); if (Rotation > 0f && Rotation < 80f) { CornerTexture.Flip = SpriteEffects.FlipHorizontally; CornerTexture.Position = position; CornerTexture.Rotation = 0f; CornerTexture.Draw(camera); CornerTexture.Flip = SpriteEffects.None; CornerTexture.Position = new Vector2(position2.X - CornerTexture.Width / 2f, position2.Y); CornerTexture.Rotation = 0f; CornerTexture.Draw(camera); } if (Rotation < 0f && Rotation > -80f) { CornerTexture.Flip = SpriteEffects.FlipHorizontally; CornerTexture.Position = position; CornerTexture.X += CornerTexture.Width / 2f; CornerTexture.Rotation = 0f; CornerTexture.Draw(camera); CornerTexture.Flip = SpriteEffects.None; CornerTexture.Position = position2; CornerTexture.Rotation = 0f; CornerTexture.Draw(camera); } camera.Draw(texture2D, new Vector2( X + TextureOffset.X - (float)Math.Sin(MathHelper.ToRadians(Rotation)) * TextureOffset.Y, Y + (float)Math.Cos(MathHelper.ToRadians(Rotation)) * TextureOffset.Y), new Rectangle(0, 0, (int)(Width / TextureScale.X), texture2D.Height), TextureColor, MathHelper.ToRadians(Rotation), Vector2.Zero, TextureScale, SpriteEffects.None, 0f); } } base.Draw(camera); }
public void DrawCorners(Camera2D camera) { CornerTexture.TextureColor = TextureColor; CornerLTexture.TextureColor = TextureColor; CornerLTexture.Flip = SpriteEffects.None; CornerTexture.Flip = SpriteEffects.None; CornerLTexture.Rotation = 0f; if (BorderTop) { if (BorderRight) { CornerLTexture.Position = new Vector2(Bounds.Right - CornerLTexture.Width, Bounds.Top); CornerLTexture.Draw(camera); } else { CornerTexture.Position = new Vector2(Bounds.Right - CornerTexture.Width, Bounds.Top); CornerTexture.Draw(camera); } CornerLTexture.Flip = SpriteEffects.FlipHorizontally; CornerTexture.Flip = SpriteEffects.FlipHorizontally; if (BorderLeft) { CornerLTexture.Position = new Vector2(Bounds.Left + CornerLTexture.Width, Bounds.Top); CornerLTexture.Draw(camera); } else { CornerTexture.Position = new Vector2(Bounds.Left + CornerTexture.Width, Bounds.Top); CornerTexture.Draw(camera); } } if (BorderBottom) { CornerTexture.Flip = SpriteEffects.FlipVertically; CornerLTexture.Flip = SpriteEffects.FlipVertically; if (BorderRight) { CornerLTexture.Position = new Vector2(Bounds.Right - CornerLTexture.Width, Bounds.Bottom - CornerLTexture.Height); CornerLTexture.Draw(camera); } else { CornerTexture.Flip = SpriteEffects.FlipVertically; CornerTexture.Position = new Vector2(Bounds.Right - CornerTexture.Width, Bounds.Bottom - CornerTexture.Height); CornerTexture.Draw(camera); } if (BorderLeft) { CornerLTexture.Position = new Vector2(Bounds.Left + CornerLTexture.Width, Bounds.Bottom - CornerLTexture.Height); CornerLTexture.Rotation = 90f; CornerLTexture.Draw(camera); CornerLTexture.Rotation = 0f; } else { CornerTexture.Flip = SpriteEffects.None; CornerTexture.Position = new Vector2(Bounds.Left + CornerTexture.Width, Bounds.Bottom); CornerTexture.Rotation = 180f; CornerTexture.Draw(camera); CornerTexture.Rotation = 0f; } } if (BorderLeft) { CornerTexture.Flip = SpriteEffects.None; CornerLTexture.Flip = SpriteEffects.None; if (!BorderBottom) { CornerTexture.Position = new Vector2(Bounds.Left, Bounds.Bottom - CornerTexture.Width); CornerTexture.Flip = SpriteEffects.FlipHorizontally; CornerTexture.Rotation = -90f; CornerTexture.Draw(camera); CornerTexture.Rotation = 0f; } if (!BorderTop) { CornerTexture.Position = new Vector2(Bounds.Left, Bounds.Top + CornerTexture.Width); CornerTexture.Flip = SpriteEffects.None; CornerTexture.Rotation = -90f; CornerTexture.Draw(camera); CornerTexture.Rotation = 0f; } } if (BorderRight) { CornerTexture.Flip = SpriteEffects.None; CornerLTexture.Flip = SpriteEffects.None; if (!BorderBottom) { CornerTexture.Position = new Vector2(Bounds.Right, Bounds.Bottom - CornerTexture.Width); CornerTexture.Rotation = 90f; CornerTexture.Draw(camera); CornerTexture.Rotation = 0f; } if (!BorderTop) { CornerTexture.Position = new Vector2(Bounds.Right, Bounds.Top + CornerTexture.Width); CornerTexture.Flip = SpriteEffects.FlipHorizontally; CornerTexture.Rotation = 90f; CornerTexture.Draw(camera); CornerTexture.Rotation = 0f; } } }