protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(); switch (currentMode) { case MODE.GAME: game.Draw(gameTime, spriteBatch); break; case MODE.WELCOME: welcomeScr.Draw(gameTime, spriteBatch); break; case MODE.LOADING: loadingScr.Draw(gameTime, spriteBatch); break; case MODE.CREDITS: creditsScr.Draw(gameTime, spriteBatch); break; case MODE.CONFIG: configScr.Draw(gameTime, spriteBatch); break; case MODE.HELP: helpScr.Draw(gameTime, spriteBatch); break; case MODE.END: endScr.Draw(gameTime, spriteBatch); break; } spriteBatch.End(); base.Draw(gameTime); }
/// <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) { GraphicsDevice.Clear(Color.Black); if (currentGameState == GameState.PLAY) { IsMouseVisible = false; // draw objects //spriteBatch.Begin(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, camera.transform); //testExMap.Draw(spriteBatch); base.Draw(gameTime); spriteBatch.End(); } if (currentGameState == GameState.START) { //spriteBatch.Begin(); splashScreen.Draw(gameTime); //spriteBatch.End(); } if (currentGameState == GameState.MENU) { menuScreen.Draw(gameTime); IsMouseVisible = true; } if (currentGameState == GameState.PAUSE) { pauseScreen.Draw(gameTime); } if (currentGameState == GameState.WIN || currentGameState == GameState.LOSE) { endScreen.Draw(gameTime); } if (currentGameState == GameState.TUT) { tutScreen.Draw(gameTime); } //draw hud if (currentGameState == GameState.PLAY) { elements.Draw(spriteBatch); spriteBatch.Begin(); if (objShow) { if (gameObj == Objective.Scientist) { spriteBatch.DrawString(objFont, "objective: find the scientist", new Vector2(32, 32), Color.Black); } if (gameObj == Objective.Scientist2) { spriteBatch.DrawString(objFont, "objective: get back to the scientist", new Vector2(32, 32), Color.Black); } if (gameObj == Objective.Cure) { spriteBatch.DrawString(objFont, "objective: find the cure", new Vector2(32, 32), Color.Black); } if (gameObj == Objective.Bomb) { spriteBatch.DrawString(objFont, "objective: find and arm the bomb", new Vector2(32, 32), Color.Black); } if (gameObj == Objective.Helicopter1 || gameObj == Objective.Helicopter2) { spriteBatch.DrawString(objFont, "objective: get to the helicopter", new Vector2(32, 32), Color.Black); } if (gameObj == Objective.Elimination) { spriteBatch.DrawString(objFont, "objective: eliminate " + objEliminate + " hostiles", new Vector2(32, 32), Color.Black); } } spriteBatch.End(); } }
// 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); }