/// <summary> /// 当游戏需要绘制时会被调用 /// </summary> /// <param name="gameTime">提供一个游戏时间快照.</param> public override void Draw(GameTime gameTime) { if (State == GameState.Menu) { playerSettings.Draw(gameTime); } else if (State == GameState.StartLoad || State == GameState.Loading) { loading.Draw(gameTime); } else if (State == GameState.CheckLoaded) { loading.Draw(gameTime); } else if (State == GameState.InGame) { board.Draw(gameTime); } else if (State == GameState.Pause) { playerSettings.Draw(gameTime); } else if (State == GameState.Over) { } if (GameSettings.ShowFPS) { fpsCounter.Draw(gameTime); } base.Draw(gameTime); }
public override void Draw(GameTime gameTime) { sb.Begin(); screenManager.Draw(sb); messageLog.Draw(sb); console.Draw(gameTime, sb); fpsCounter.Draw(sb); mouse.Draw(sb); sb.End(); }
public void drawUI(SpriteBatch spriteBatch, GameTime gameTime) { spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.Opaque, Settings.SAMPLER_STATE, DepthStencilState.Default, RasterizerState.CullNone, Settings.GLOBAL_SHADER, Camera.Main.Transform); healthBar.Draw(spriteBatch, Camera.Main); fpsCounter.Update(gameTime); fpsCounter.Draw(spriteBatch, Camera.Main); spriteBatch.End(); }
public void Draw() { fpsCounter.Draw(window); if (currentScreen is GameScreen) { camera.Center = (currentScreen as GameScreen).PlayerShip.Position; window.SetView(camera); } else { window.SetView(window.DefaultView); } background.Draw(window); if (currentScreen != null) { currentScreen.Draw(window); } Input.Mouse.Draw(window); }
public void Draw(CanvasDrawingSession drawingSession, CanvasTimingInformation timing) { float pulseTime(float period) { float modTime = (float)(timing.TotalTime.TotalMilliseconds % period); if (modTime < period / 2) { return(modTime / (period / 2)); } else { return(1 - (modTime - period / 2) / (period / 2)); } } fpsCounter.Draw(timing); using (var ds = bloomRendering.CreateDrawingSession()) { ds.Clear(Colors.Black); ds.Transform = Camera.Transform; for (float x = -EntityManager.GameSize + 100; x < EntityManager.GameSize; x += 100) { ds.DrawLine(new Vector2(x, -EntityManager.GameSize), new Vector2(x, EntityManager.GameSize), Color.FromArgb(255, 20, 0, 0), 2); } for (float y = -EntityManager.GameSize + 100; y < EntityManager.GameSize; y += 100) { ds.DrawLine(new Vector2(-EntityManager.GameSize, y), new Vector2(EntityManager.GameSize, y), Color.FromArgb(255, 20, 0, 0), 2); } using (var spriteBatch = ds.CreateSpriteBatch()) { EntityRenderer.Draw(spriteBatch, timing); } float pulse = pulseTime(1000); ds.DrawLine(new Vector2(-EntityManager.GameSize, -EntityManager.GameSize), new Vector2(-EntityManager.GameSize, EntityManager.GameSize), Colors.OrangeRed, 3 + pulse * 2); ds.DrawLine(new Vector2(EntityManager.GameSize, -EntityManager.GameSize), new Vector2(EntityManager.GameSize, EntityManager.GameSize), Colors.OrangeRed, 3 + pulse * 2); ds.DrawLine(new Vector2(-EntityManager.GameSize, EntityManager.GameSize), new Vector2(EntityManager.GameSize, EntityManager.GameSize), Colors.OrangeRed, 3 + pulse * 2); ds.DrawLine(new Vector2(-EntityManager.GameSize, -EntityManager.GameSize), new Vector2(EntityManager.GameSize, -EntityManager.GameSize), Colors.OrangeRed, 3 + pulse * 2); } bloomRendering.DrawResult(drawingSession); foreach (var player in EntityManager.Entities.Where(e => e is Player).Cast <Player>()) { var playerColor = Color.FromArgb((byte)(player.Color.W * 255), (byte)(player.Color.X * 255), (byte)(player.Color.Y * 255), (byte)(player.Color.Z * 255)); var playerPosition = Vector2.Transform(player.Position, Camera.Transform); var textLayout = new CanvasTextLayout(drawingSession, player.Name, new CanvasTextFormat { FontSize = 12 }, 256.0f, 32.0f) { WordWrapping = CanvasWordWrapping.NoWrap }; var textSize = textLayout.LayoutBounds; drawingSession.DrawTextLayout(textLayout, playerPosition - new Vector2((float)(textSize.Width / 2), (float)(textSize.Height / 2 + 64)), playerColor); drawingSession.DrawRectangle(new Rect(playerPosition.X - 32, playerPosition.Y - 48, 64f, 8), playerColor); if (player.Health > 0) { drawingSession.FillRectangle(new Rect(playerPosition.X - 32, playerPosition.Y - 48, 64f * player.Health / 100f, 8), playerColor); } if (player.Shield > 0) { drawingSession.FillRectangle(new Rect(playerPosition.X - 32, playerPosition.Y - 48, 64f * player.Shield / 100f, 8), Colors.Aquamarine); } } drawingSession.DrawText("FPS: " + fpsCounter.FPS, new Vector2(0, 0), fpsCounter.FPS > 50 ? Colors.LimeGreen : fpsCounter.FPS > 40 ? Colors.YellowGreen : fpsCounter.FPS > 30 ? Colors.Yellow : fpsCounter.FPS > 20 ? Colors.Orange : fpsCounter.FPS > 10 ? Colors.OrangeRed : Colors.Red); drawingSession.DrawText("Ping: " + Math.Round(gameServer.PingMS), new Vector2(0, 32), gameServer.PingMS < 25 ? Colors.LimeGreen : gameServer.PingMS < 50 ? Colors.YellowGreen : gameServer.PingMS < 100 ? Colors.Yellow : gameServer.PingMS < 150 ? Colors.Orange : gameServer.PingMS < 300 ? Colors.OrangeRed : Colors.Red); drawingSession.DrawText(DebugString ?? "", new Vector2(0, 64), Colors.Wheat); }
public override void DrawStaticSprites(GameTime time) { entityManager.DrawStatic(time); fps.Draw(time); }