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.
 
 
 

41 lines
1.3 KiB

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System.IO;
// All extension methods on built-in types (of C# or MonoGame) go in this file.
// Methods are ordered alphabetically by type name.
namespace SemiColinGames {
public static class ExtensionMethods {
// ContentManager
public static string LoadString(this ContentManager content, string path) {
string fullPath = Path.Combine(content.RootDirectory, path);
return File.ReadAllText(fullPath);
}
// Point
public static void Deconstruct(this Point point, out int x, out int y) =>
(x, y) = (point.X, point.Y);
// Rectangle
public static Vector2 HalfSize(this Rectangle rect) {
return new Vector2(rect.Width / 2, rect.Height / 2);
}
// SpriteFont
public static Vector2 CenteredOn(this SpriteFont font, string text, Point position) {
Vector2 size = font.MeasureString(text);
return new Vector2(position.X - (int) size.X / 2, position.Y - (int) size.Y / 2);
}
// Vector2
public static Vector2 Rotate(this Vector2 point, float angle) {
float cos = FMath.Cos(angle);
float sin = FMath.Sin(angle);
return new Vector2(
point.X * cos - point.Y * sin,
point.Y * cos + point.X * sin);
}
}
}