コード例 #1
0
        protected override void Draw(GameTime gameTime)
        {
            spriteBatch.Begin();

            if (gameState == GameState.StartMenu)
            {
                spriteBatch.Draw(menu_background, new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), Color.White);
                spriteBatch.Draw(menuTitle, new Rectangle((GraphicsDevice.Viewport.Width / 2) - (menuTitle.Width / 2), 20, menuTitle.Width, menuTitle.Height), null, Color.White);
                spriteBatch.Draw(menuPlanetBackground, new Rectangle((GraphicsDevice.Viewport.Width / 2) - (menuPlanetBackground.Width / 2), 200,
                                                                     menuPlanetBackground.Width / (6 / 5), menuPlanetBackground.Height / (6 / 5)), Color.White);
                spriteBatch.Draw(playerNameHUD, new Rectangle(0, 300, playerNameHUD.Width, playerNameHUD.Height), Color.White);
                playButton.Draw(spriteBatch);
                quitButton.Draw(spriteBatch);
                checkButton.Draw(spriteBatch);

                if (checkedPlayerName == "")
                {
                    spriteBatch.DrawString(font, playerName, new Vector2(25, 335), Color.Black);
                }
                else
                {
                    spriteBatch.DrawString(font, checkedPlayerName, new Vector2(25, 335), Color.Black);
                }
            }

            if (gameState == GameState.LevelMenu)
            {
                spriteBatch.Draw(menu_background, new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), Color.White);
                if (levelMenu1 == true)
                {
                    nivel1Button.Draw(spriteBatch);
                    nivel2Button.Draw(spriteBatch);
                    nivel3Button.Draw(spriteBatch);
                    nivel4Button.Draw(spriteBatch);
                    nivel5Button.Draw(spriteBatch);
                    nivel6Button.Draw(spriteBatch);
                    previousMenuButton.Draw(spriteBatch);
                    nextMenuButton.Draw(spriteBatch);
                }
                if (levelMenu2 == true)
                {
                    nivel7Button.Draw(spriteBatch);
                    nivel8Button.Draw(spriteBatch);
                    nivel9Button.Draw(spriteBatch);
                    nivel10Button.Draw(spriteBatch);
                    nivel11Button.Draw(spriteBatch);
                    nivel12Button.Draw(spriteBatch);
                    previousMenuButton.Draw(spriteBatch);
                }
            }

            if (gameState == GameState.Playing)
            {
                spriteBatch.Draw(play_background, new Rectangle(0, 0, GraphicsDevice.Viewport.Width
                                                                , GraphicsDevice.Viewport.Height), Color.White);
                // Draws score
                spriteBatch.DrawString(font, "Orbiting Score: " + currentLevel.orbitingScore.ToString(), new Vector2(15, 500), Color.White);

                DrawTrajectory((float)gameTime.ElapsedGameTime.TotalSeconds);

                // Draws shooted flask
                if (flask != null)
                {
                    flask.Draw(spriteBatch);
                }

                // Draws planets on screeen
                foreach (Planet p in currentLevel.planetList)
                {
                    p.Draw(spriteBatch);
                }

                // Draws flasks on screeen
                foreach (Flask f in currentLevel.flaskList)
                {
                    f.Draw(spriteBatch);
                }

                // Draws current level
                if (Level.n_level == 0)
                {
                    spriteBatch.Draw(lvl1, new Rectangle(1100, 10, 175, 50), Color.White);
                }
                if (Level.n_level == 1)
                {
                    spriteBatch.Draw(lvl2, new Rectangle(1100, 10, 175, 50), Color.White);
                }
                if (Level.n_level == 2)
                {
                    spriteBatch.Draw(lvl3, new Rectangle(1100, 10, 175, 50), Color.White);
                }
                if (Level.n_level == 3)
                {
                    spriteBatch.Draw(lvl4, new Rectangle(1100, 10, 175, 50), Color.White);
                }
                if (Level.n_level == 4)
                {
                    spriteBatch.Draw(lvl5, new Rectangle(1100, 10, 175, 50), Color.White);
                }
                if (Level.n_level == 5)
                {
                    spriteBatch.Draw(lvl6, new Rectangle(1100, 10, 175, 50), Color.White);
                }

                spriteBatch.Draw(astronaut, new Rectangle(-5, 5, 230, 480), Color.White);


                gun.Draw(spriteBatch);

                if (isPaused == true)
                {
                    spriteBatch.Draw(pauseHUD, new Rectangle((GraphicsDevice.Viewport.Width / 2) - (pauseHUD.Width / 2), 100, pauseHUD.Width, pauseHUD.Height), Color.White);
                    pauseResumeButton.Draw(spriteBatch);
                    pauseMenuButton.Draw(spriteBatch);
                    pauseRestartButton.Draw(spriteBatch);
                }
                else
                {
                    pauseButton.Draw(spriteBatch);
                }

                if (currentLevel.IsFinished == true)
                {
                    spriteBatch.Draw(finishHUD, new Rectangle((GraphicsDevice.Viewport.Width / 2) - (finishHUD.Width / 2), 0, finishHUD.Width, finishHUD.Height), Color.White);
                    currentLevel.DrawFinish(spriteBatch);
                    finalRetryButton.Draw(spriteBatch);
                }
            }
            if (gameState == GameState.GameOver)
            {
                spriteBatch.Draw(menu_background, new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), Color.White);
                spriteBatch.Draw(gameoverHUD, new Rectangle((GraphicsDevice.Viewport.Width / 2) - (gameoverHUD.Width / 2), 100, gameoverHUD.Width, gameoverHUD.Height), Color.White);
                gameoverMenuButton.Draw(spriteBatch);
                gameoverRetryButton.Draw(spriteBatch);
            }
            spriteBatch.Draw(cursor, cursorPos, Color.White);
            spriteBatch.End();
            base.Draw(gameTime);
        }