/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); spriteBatch.Draw(Locator.getTextureManager().getTexture(bg_tex_id), Vector2.Zero, Color.White); spriteBatch.End(); Locator.getComponentManager().render(spriteBatch); Locator.getControlManager().render(spriteBatch); base.Draw(gameTime); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); Locator.provide(ScreenPrinter.init(Content.Load <SpriteFont>("LargeFont"), Content.Load <SpriteFont>("SmallFont"))); Locator.provide(TextureManager.init(GraphicsDevice, Content)); Ship.loadTextures(); bg_tex_id = Locator.getTextureManager().loadTexture("spacebg"); world = new GameEntity(); world.spatial = new SpatialComponent(world, new Vector2(400, 300), 0, Vector2.One); world.controller = new WorldController(world, screen); Locator.getComponentManager().addEntity(world); Locator.provideWorld(world); Locator.provide(Ship.init(world)); ObjectFactory ob = new ObjectFactory(); ob.init(); Locator.provide(ob); Locator.getShip().populate(); Locator.getControlManager().forceState(new ControlStates.Selector()); player = new GameEntity(); player.spatial = new Components.SpatialComponent(player, Locator.getShip().entity_.spatial, new Vector2(900, 416), 0, Vector2.One); player.render = new Components.RenderComponent(player, Locator.getTextureManager().loadTexture("person32"), 1, new Vector2(16), Color.White); player.inventory = new InventoryComponent(player, 10); player.controller = new Components.PlayerControllerComponent(player); Locator.getComponentManager().addEntity_(player); Locator.providePlayer(player); test = new GameEntity(); test.spatial = new SpatialComponent(test, Locator.getShip().entity_.spatial, Vector2.Zero, 0, new Vector2(3)); test.render = new RenderComponent(test, -1, 0, new Vector2(0.5f), Color.White); Locator.getComponentManager().addEntity(test); Locator.provide(new WindowFactory(screen)); Locator.getControlManager().setInventory(Locator.getWindowFactory().inventoryWindow()); Locator.getMessageBoard().postMessage(new Post(PostCategory.PLACED_OBJECT)); }
public static void loadTextures() { tile_tex_id = Locator.getTextureManager().loadTexture("tile32"); }