public void TestServiceConstructor() { var services = new GameServiceContainer(); using (var manager = new InputManager(services)) { Assert.IsNotNull(services.GetService(typeof(IInputService))); } Assert.IsNull(services.GetService(typeof(IInputService))); }
public static Grid FromBitmap(GameServiceContainer services, string bitmapName) { var texture = ((ContentManager)services.GetService(typeof(ContentManager))).Load<Texture2D>(bitmapName); var grid = new Grid(texture.Width, texture.Height); for (var i = 0; i < grid.Size.Width; i++) { for (var j = 0; j < grid.Size.Height; j++) { var c = new Color[1]; texture.GetData(0, new Rectangle(i, j, 1, 1), c, 0, 1); grid.Weight[i, j] = (byte)((c[0].R + c[0].G + c[0].B)/3); } } return grid; }