//private function designed to create default HUDelements private void startup(TextureManager TM) { //GRAPHICS //create show/hide button HudGraphic showHide = new HudGraphic("showHide", new Vector2(1200, 0), new Vector2(80, 20), VISIBILITY.SHOWN, ORIENTATION.TOP, TM.UI[1], new showHide()); //create top bar //HudGraphic topBar = new HudGraphic(new Vector2(0, 0), new Vector2(1280,20), VISIBILITY.SHOWN, ORIENTATION.TOP, TM.UI[2]); //housing submenu icon HudGraphic shelter = new HudGraphic("shelter", new Vector2(0, 0), new Vector2(40, 20), VISIBILITY.SHOWN, ORIENTATION.TOP, TM.UI[3], new createSubMenu("shelter")); //create bottom bar HudGraphic bottomBar = new HudGraphic("bottomBar", new Vector2(0, 700), new Vector2(1280, 20), VISIBILITY.SHOWN, ORIENTATION.BOTTOM, TM.UI[2], new doNothing()); graphics.Add(showHide); graphics.Add(bottomBar); //graphics.Add(topBar); graphics.Add(shelter); //TEXT //current date HudText day = new HudText(new Vector2(150, 702), new Vector2(100, 20), VISIBILITY.SHOWN, ORIENTATION.BOTTOM, TM.fonts[0], "date", new doNothing()); //camera position HudText camera = new HudText(new Vector2(0, 702), new Vector2(100, 20), VISIBILITY.SHOWN, ORIENTATION.BOTTOM, TM.fonts[0], "camx, camy", new doNothing()); texts.Add(day); texts.Add(camera); }
/// <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) { int WIDTH = (G.graphicsWidth / G.tileSize); int HEIGHT = (G.graphicsHeight / G.tileSize); int i, j = 0; int camX = 0; int camY = 0; GraphicsDevice.Clear(Color.TransparentBlack); spriteBatch.Begin(); //draw TILES camX = M.getCamX(); camY = M.getCamY(); for (i = 0; i < HEIGHT; i++) { for (j = 0; j < WIDTH; j++) { tile T = M.getTileAt(camX + j, camY + i); Vector2 pos = new Vector2(j * G.tileSize, i * G.tileSize); spriteBatch.Draw(T.getTexture(), pos, null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 1f); } } //draw all HUD elements for (i = 0; i < HM.hudGraphicsCount(); i++) { //ignore hidden stuff if (HM.getGraphicAt(i).getState() == VISIBILITY.HIDDEN) { continue; } HudGraphic HG = HM.getGraphicAt(i); spriteBatch.Draw(HG.getTexture(), HG.getPosition(), null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 1f); } //draw all hud text for (i = 0; i < HM.hudTextCount(); i++) { //ignore hidden stuff if (HM.getTextAt(i).getState() == VISIBILITY.HIDDEN) { continue; } HudText HT = HM.getTextAt(i); spriteBatch.DrawString(HT.getFont(), HT.getText(), HT.getPosition(), Color.White, 0, new Vector2(0, 0), 1f, SpriteEffects.None, 0); } //draw crosshair spriteBatch.Draw(TM.crosshair, new Vector2(G.mouseX, G.mouseY), null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 1f); //draw bottom bar //spriteBatch.Draw(TM.UI[0], new Vector2(0, 700), null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 1f); //draw current position //string position = "pos:(" + camX + "," + camY + ")"; //spriteBatch.DrawString(defaultFont, position, new Vector2(0, 702), Color.White, 0, new Vector2(0, 0), 1f, SpriteEffects.None, 0); //draw current time //string date = "day:" + DT.getDay(); //spriteBatch.DrawString(defaultFont, date, new Vector2(150, 702), Color.White, 0, new Vector2(0, 0), 1f, SpriteEffects.None, 0); //draw resources base.Draw(gameTime); spriteBatch.End(); return; }