예제 #1
0
        /// <summary>
        /// Draws the message box.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            // Darken down any other screens that were drawn beneath the popup.
            ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 2 / 3);

            // Center the message text in the viewport.
            Viewport viewport     = ScreenManager.GraphicsDevice.Viewport;
            Vector2  viewportSize = new Vector2(viewport.Width, viewport.Height);
            Vector2  textSize     = font.MeasureString(message);
            Vector2  textPosition = (viewportSize - textSize) / 2;

            // The background includes a border somewhat larger than the text itself.
            const int hPad = 32;
            const int vPad = 16;

            Rectangle backgroundRectangle = new Rectangle((int)textPosition.X - hPad,
                                                          (int)textPosition.Y - vPad,
                                                          (int)textSize.X + hPad * 2,
                                                          (int)textSize.Y + vPad * 2);

            // Fade the popup alpha during transitions.
            Color color = Color.White * TransitionAlpha;

            spriteBatch.Begin();

            // Draw the background rectangle.
            //spriteBatch.Draw(gradientTexture, backgroundRectangle, color);

            // Draw the message box text.
            spriteBatch.DrawString(font, message, textPosition, color);

            spriteBatch.End();
        }
예제 #2
0
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
            SpriteFont  font        = ScreenManager.Font;

            // Darken down any other screens that were drawn beneath the popup.
            ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 4 / 3);

            // Fade the popup alpha during transitions.
            Color color = Color.White * TransitionAlpha;


            spriteBatch.Begin();

            spriteBatch.Draw(background, new Rectangle(0, 0, background.Width, background.Height), color);
            spriteBatch.Draw(menuTitle, new Rectangle(400 - (menuTitle.Width / 2), 100, menuTitle.Width, menuTitle.Height), color);

            int y = 0;

            if (got == gameOverType.COMPLETE)
            {
                spriteBatch.Draw(gameOver, new Rectangle(400 - gameOver.Width / (2 * 2), 200, gameOver.Width / 2, gameOver.Height / 2), color);
            }
            else
            {
                spriteBatch.Draw(gameOver, new Rectangle(400 - gameOver.Width / (2 * 2), 200, gameOver.Width / 2, gameOver.Height / 2), color);
            }



            spriteBatch.End();

            exitButton.Draw(spriteBatch);
            mouse.Draw(spriteBatch);
        }
예제 #3
0
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
            SpriteFont  font        = ScreenManager.Font;

            ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 0.6f);


            Color color = Color.White * TransitionAlpha;

            spriteBatch.Begin();
            spriteBatch.Draw(gradientTexture, new Rectangle((400 - gradientTexture.Width / 2), 200, gradientTexture.Width, gradientTexture.Height), color);
            spriteBatch.End();

            mouse.Draw(spriteBatch);
        }
예제 #4
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            backgroundLayer.Draw(spriteBatch, cam.position);


            foreach (TileObject c in objList)
            {
                c.Draw(spriteBatch);
            }

            foreach (Enemy e in enemyList)
            {
                e.Draw(spriteBatch);
            }

            foreach (AnimatedSprite a in animList)
            {
                a.Draw(spriteBatch, a.pos, 0.0f);
            }

            player.Draw(spriteBatch);

            int hx = 10;
            int hy = 50;


            spriteBatch.Begin();

            for (int i = 0; i < player._lives; i++)
            {
                spriteBatch.Draw(heart, new Rectangle(hx, hy, heart.Width / 2, heart.Height / 2), Color.White);
                hx += heart.Width / 2 + 10;
            }

            spriteBatch.DrawString(spriteFont, "Score : " + player.score, new Vector2(10, 90), Color.White);
            spriteBatch.End();

            if (TransitionPosition > 0 || pauseAlpha > 0)
            {
                float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2);

                ScreenManager.FadeBackBufferToBlack(alpha);
            }
        }
예제 #5
0
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
            SpriteFont  font        = ScreenManager.Font;


            ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 4 / 3);
            Color color = Color.White * TransitionAlpha;



            int diffBonus;

            if (gameDiff == GameDifficulty.EASY_MODE)
            {
                diffBonus = 1;
            }
            else
            {
                diffBonus = 2;
            }

            int totalScore = score + ((10 * lives) * diffBonus);

            player.score = totalScore;

            String scoreString = String.Format("Level Score        :   {0:00}" +
                                               "\nLives Left         :   {1:00}" +
                                               "\nDifficulty Bonus   :   {2:00}" +
                                               "\n\nTOTAL SCORE        :   {3:00}"
                                               , score, lives, diffBonus, totalScore);

            spriteBatch.Begin();


            spriteBatch.Draw(background, new Rectangle(0, 10, background.Width, background.Height), color);
            spriteBatch.DrawString(font, scoreString, new Vector2(800 / 2 - 150, 250), Color.White);
            spriteBatch.Draw(gameOver, new Rectangle(800 / 2 - gameOver.Width / 2, 100, gameOver.Width, gameOver.Height), color);

            spriteBatch.End();

            exitButton.Draw(spriteBatch);
            mouse.Draw(spriteBatch);
        }
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
            SpriteFont  font        = ScreenManager.Font;

            ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 4 / 3);
            Color color = Color.White * TransitionAlpha;


            spriteBatch.Begin();

            spriteBatch.DrawString(font, "#", new Vector2(200, 200), Color.White);
            spriteBatch.DrawString(font, "Name", new Vector2(360, 200), Color.White);
            spriteBatch.DrawString(font, "Score", new Vector2(520, 200), Color.White);

            Color c = Color.White;

            for (int i = 0; i < 10; i++)
            {
                int y = 220 + (i + 1) * 25;
                int j = i + 1;

                if (p != null && p.score == highScores.scores[i] && p.name == highScores.names[i])
                {
                    c = Color.Red;
                }
                else
                {
                    c = Color.White;
                }

                spriteBatch.DrawString(font, j.ToString(), new Vector2(200, y), c);
                spriteBatch.DrawString(font, highScores.names[i].ToUpper(), new Vector2(360, y), c);
                spriteBatch.DrawString(font, highScores.scores[i].ToString(), new Vector2(520, y), c);
            }
            spriteBatch.Draw(zombie, new Rectangle(0, 10, zombie.Width, zombie.Height), Color.White);
            spriteBatch.Draw(banner, new Rectangle((800 / 2) - (banner.Width / 2), 100, banner.Width, banner.Height), Color.White);

            spriteBatch.End();

            exitButton.Draw(spriteBatch);
            mouse.Draw(spriteBatch);
        }