public override void DrawAbove(GameContext context) { XnaGraphics xna = new XnaGraphics(context); //this.m_FieldOfViewRenderer.Render(context, xna); //int i = 0; //foreach (IPositionable p in this.m_Uniques) // xna.DrawStringLeft(8, 8 + (i++) * 16, p.ToString()); xna.DrawStringLeft(8, 8, "FPS: " + context.FPS, "Arial"); }
public void Draw(RTSWorld world, GameContext context, XnaGraphics graphics) { this.Update(world, context); graphics.DrawStringLeft(0, 0, world.ActiveLevel.GetType().Name); graphics.DrawStringLeft(0, 32, this.m_Tick.ToString()); if (this.m_LastMousePoint.HasValue && this.m_CurrentMousePoint.HasValue) graphics.DrawRectangle(this.m_LastMousePoint.Value, this.m_CurrentMousePoint.Value, Color.LimeGreen); foreach (Unit u in this.Selected) { Rectangle bb = new Rectangle((int)u.X, (int)u.Y - 1, u.Width + 1, u.Height + 1); if (u.Team != null) graphics.DrawRectangle(bb, u.Team.Color); else graphics.DrawRectangle(bb, Color.LimeGreen); } // Draw chat. int a = 16; for (int i = this.m_ChatMessages.Count - 1; i >= Math.Max(this.m_ChatMessages.Count - 11, 0); i--) { if (i < this.m_ChatMessages.Count) graphics.DrawStringLeft(0, context.Graphics.GraphicsDevice.Viewport.Height - a, this.m_ChatMessages[i]); a += 16; } // Draw graph. if (this.m_GraphFrames.Count > 1) { for (int i = 1; i < this.m_GraphFrames.Count; i++) graphics.DrawLine(i - 1, (float)this.m_GraphFrames[i - 1], i, (float)this.m_GraphFrames[i], 1, Color.Lime); } // Add frame information. if (this.m_GraphFrames.Count > 200) this.m_GraphFrames.RemoveAt(0); this.m_GraphFrames.Add(context.GameTime.ElapsedGameTime.TotalMilliseconds); this.m_Tick++; }
public void Render(GameContext context, XnaGraphics xna) { Point center = this.m_FieldOfView.World.GetCenter(); for (int x = 0; x < this.m_FieldOfView.BroadphaseGrid.GetLength(0); x++) for (int y = 0; y < this.m_FieldOfView.BroadphaseGrid.GetLength(1); y++) { if (!this.m_FieldOfView.BroadphaseGrid[x, y]) xna.FillRectangle(new Rectangle(x * Seperation, y * Seperation, Seperation, Seperation), new Color(0f, 0f, 0f, 0.4f).ToPremultiplied()); if (x == center.X && y == center.Y) xna.FillRectangle(new Rectangle(x * Seperation, y * Seperation, Seperation, Seperation), new Color(1f, 0f, 0f, 1).ToPremultiplied()); //xna.DrawStringLeft(x * Seperation, y * Seperation, this.m_FieldOfView.m_BroadphaseHeightGrid[x, y].ToString()); int deg = (int)MathHelper.ToDegrees(this.m_FieldOfView.m_BroadphaseAngleGrid[x, y]); xna.DrawStringLeft(x * Seperation, y * Seperation, deg.ToString(), "SmallArial"); /*if (deg < -100) xna.DrawStringLeft(x * Seperation, y * Seperation, Math.Abs(deg + 100).ToString()); else if (deg < 0) xna.DrawStringLeft(x * Seperation, y * Seperation, Math.Abs(deg).ToString()); else if (deg < 100) xna.DrawStringLeft(x * Seperation, y * Seperation, (deg).ToString()); else if (deg < 200) xna.DrawStringLeft(x * Seperation, y * Seperation, (deg - 100).ToString());*/ } }
public override void DrawAbove(GameContext context) { // Are we waiting for players? #if MULTIPLAYER if (this.m_GlobalSession.Waiting || (this.m_GlobalSession.LoadingInitialData && !LocalNode.Singleton.IsServer)) #else if (this.m_GlobalSession.Waiting) #endif { XnaGraphics graphics = new XnaGraphics(context); graphics.FillRectangle(new Rectangle(0, 0, context.Graphics.GraphicsDevice.Viewport.Width, context.Graphics.GraphicsDevice.Viewport.Height), Color.Black); int dialogX = context.Graphics.GraphicsDevice.Viewport.X + context.Graphics.GraphicsDevice.Viewport.Width / 2 - 300; int dialogY = context.Graphics.GraphicsDevice.Viewport.Y + context.Graphics.GraphicsDevice.Viewport.Height / 2 - 200; graphics.FillRectangle(new Rectangle(dialogX, dialogY, 600, 400), Color.DarkSlateGray); graphics.DrawStringCentered(dialogX + 300, dialogY + 8, this.m_GlobalSession.LobbyMessage, "BigArial"); graphics.DrawStringCentered(dialogX + 300, dialogY + 32, "Press enter to toggle ready status."); int a = 0; for (int i = 0; i < this.m_GlobalSession.Players.Count; i++) { Player p = this.m_GlobalSession.Players[i]; if (p.Ready) graphics.DrawStringLeft(dialogX + 8, dialogY + 48 + a * 16, "Player " + a + " (" + p.PlayerID + ") ready."); else graphics.DrawStringLeft(dialogX + 8, dialogY + 48 + a * 16, "Player " + a + " (" + p.PlayerID + ") not ready."); a++; } return; } // Handle game normally. if (this.m_ActiveLevel != null) this.m_ActiveLevel.DrawAbove(context); this.m_UiManager.Draw(this, context, new XnaGraphics(context)); }