/// <summary> /// Draw this state /// </summary> /// <param name="GameTime">Snapshot of timing</param> public override void Draw(GameTime GameTime) { var MapTexture = MapView.DrawMap(GameTime, AppSpriteBatch); AppSpriteBatch.Begin(); AppSpriteBatch.Draw(MapTexture, new Vector2(0.0f, 0.0f), Color.White); DrawLog(new Vector2(800.0f, 10.0f)); DrawStats(new Vector2(800.0f, 100.0f)); AppSpriteBatch.End(); }
/// <summary> /// Draw this state /// </summary> /// <param name="GameTime">Snapshot of timing</param> public override void Draw(GameTime GameTime) { // Draw map to texture // Needs to happen before sprite batch begins, as it needs to begin it itself with a // different RenderTarget var MapTexture = MapView.DrawMap(GameTime, AppSpriteBatch); // Scale, in case high DPI float scale = (float)ScreenWidth / (float)MapTexture.Width; // Scale for log // Should stay a consistent size... it's twice the DPI of my real life screen, which // means that 14pt is about half the physical size on the phone as it is on my screen // which feels about right to me, I guess float logScale = Dpi / 220; AppSpriteBatch.Begin(); // Draw map texture to screen AppSpriteBatch.Draw(MapTexture, // VS's clam that (float) is redundant is a lie. If it's not cast - no right side // off new Rectangle(0, 0, (int)((float)MapTexture.Width * scale), (int)((float)MapTexture.Height * scale)), Color.White); // Draw guides if (ShowGuides) { float regionWidth = ScreenWidth / 3; float regionHeight = ScreenHeight / 4; for (int ix = 0; ix < 3; ix++) { AppSpriteBatch.DrawLine(new Vector2(ix * regionWidth, 0), new Vector2(ix * regionWidth, ScreenHeight), Color.Gray); } for (int iy = 0; iy < 4; iy++) { AppSpriteBatch.DrawLine(new Vector2(0, iy * regionHeight), new Vector2(ScreenWidth, iy * regionHeight), Color.Gray); } } // Draw log on bottom of screen float currentLineY = ScreenHeight; foreach (var message in G.LastTurnMessages) { currentLineY -= logScale * LogFont.MeasureString(message.ToString()).Y; } foreach (var message in G.LastTurnMessages) { var coord = new Vector2(0, currentLineY); var messageDimensions = LogFont.MeasureString(message.ToString()); AppSpriteBatch.DrawString(LogFont, message.ToString(), coord, Color.White, 0.0f, new Vector2(0.0f, 0.0f), logScale, SpriteEffects.None, 1.0f); currentLineY += messageDimensions.Y; } // Draw stats string statText = $"HP {G.Player.CurrentHealth} ({G.Player.MaxHealth})"; AppSpriteBatch.DrawString(StatFont, statText, new Vector2(10.0f, (float)MapTexture.Height * scale), Color.Red, 0.0f, new Vector2(0.0f, 0.0f), logScale, SpriteEffects.None, 0); AppSpriteBatch.End(); }