예제 #1
0
        // Draw
        protected override void Draw(GameTime gameTime)
        {
            graphics.SynchronizeWithVerticalRetrace = false;

            GraphicsDevice.Clear(Color.DarkOliveGreen);
            spriteBatch.Begin();

            if (GameManager.GameState == GameManager.GameStates.PlayScreen || endScreen.fadein)
            {
                spriteBatch.Draw(Art.Background, Vector2.Zero, Color.DarkGray);
                GameManager.grid.Draw(spriteBatch, Art.DebugFont);
                UiManager.Draw(spriteBatch);
                GameManager.Draw(spriteBatch);
            }

            if (GameManager.GameState == GameManager.GameStates.InfoScreen)
            {
                infoScreen.Draw(spriteBatch);
            }

            if (GameManager.GameState == GameManager.GameStates.StartVideo || GameManager.GameState == GameManager.GameStates.TutScreen)
            {
                if (GameManager.videoPlayer.State != MediaState.Stopped)
                {
                    Texture2D texture = GameManager.videoPlayer.GetTexture();
                    if (texture != null)
                    {
                        spriteBatch.Draw(texture, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight),
                                         Color.White);
                    }
                }
            }

            if (GameManager.GameState == GameManager.GameStates.StartScreen || startScreen.fadeout)
            {
                startScreen.Draw(spriteBatch);
            }

            if (GameManager.GameState == GameManager.GameStates.LoseScreen || endScreen.fadeout)
            {
                endScreen.Draw(spriteBatch);
            }


#if DEBUG
            // Draw debug text. Shadow on offset, then white text on top for visibility.

            /*if (!float.IsInfinity(1 / (float)gameTime.ElapsedGameTime.TotalSeconds))
             * {
             *  for (int i = 0; i < 2; i++)
             *  {
             *      spriteBatch.DrawString(Art.DebugFont,
             *          "DEBUG" +
             *          "\nFPS: " + (1 / (float)gameTime.ElapsedGameTime.TotalSeconds).ToString("") +
             *          "\nBuild: " + GameManager.BuildState +
             *          "\nEnemySpawn: " + WaveManager.EnemySpawnTimer,
             *          i < 1 ? Vector2.One : Vector2.Zero,     // if (i<1) {Vec.One} else {Vec.Zero}
             *          i < 1 ? Color.Black : Color.White);     // if (i<1) {C.Black} else {C.White}
             *  }
             * }
             *
             * //spriteBatch.DrawString(Art.DebugFont, tanks.ScreenPos.X + " " + tanks.ScreenPos.Y, tanks.ScreenPos, Color.Black);*/
#endif


            // Finish spriteBatch.
            spriteBatch.End();

            base.Draw(gameTime);
        }