GetService() public method

public GetService ( Type type ) : object
type Type
return object
Ejemplo n.º 1
0
    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)));
    }
Ejemplo n.º 2
0
        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;
        }