A stealth-based 2D platformer where you don't have to kill anyone unless you want to. https://www.semicolin.games
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.2 KiB

  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Content;
  3. using Microsoft.Xna.Framework.Graphics;
  4. using System.IO;
  5. // All extension methods on built-in types (of C# or MonoGame) go in this file.
  6. // Methods are ordered alphabetically by type name.
  7. namespace SemiColinGames {
  8. public static class ExtensionMethods {
  9. // ContentManager
  10. public static string LoadString(this ContentManager content, string path) {
  11. string fullPath = Path.Combine(content.RootDirectory, path);
  12. return File.ReadAllText(fullPath);
  13. }
  14. // Point
  15. public static void Deconstruct(this Point point, out int x, out int y) =>
  16. (x, y) = (point.X, point.Y);
  17. // SpriteFont
  18. public static Vector2 CenteredOn(this SpriteFont font, string text, Point position) {
  19. Vector2 size = font.MeasureString(text);
  20. return new Vector2(position.X - (int) size.X / 2, position.Y - (int) size.Y / 2);
  21. }
  22. // Vector2
  23. public static Vector2 Rotate(this Vector2 point, float angle) {
  24. float cos = FMath.Cos(angle);
  25. float sin = FMath.Sin(angle);
  26. return new Vector2(
  27. point.X * cos - point.Y * sin,
  28. point.Y * cos + point.X * sin);
  29. }
  30. }
  31. }