/// <summary>
        /// This is called when the movie should draw itself.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // Clear background
            ScreenManager.GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();

            // Draw current frame
            spriteBatch.Draw(movie[currentMovieFrame], new Vector2((gameWidth / 2) - (movieWidth / 2), (gameHeight / 2) - (movieHeight / 2)), Color.White);

            spriteBatch.End();

            // If the screen is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0)
            {
                ScreenManager.FadeBackBufferToBlack(255 - TransitionAlpha);
            }
        }
Example #2
0
        /// <summary>
        /// Draws the message box.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // Start to transition the Screen off if it's been on for more than 3 seconds
            if (DateTime.Now >= offAt)
            {
                ExitScreen();
            }
            else
            {
                SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
                SpriteFont  font        = ScreenManager.Font;

                // 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("Game Over");
                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 = new Color(255, 255, 255, TransitionAlpha);

                spriteBatch.Begin();

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

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

                spriteBatch.End();
            }
        }
        /// <summary>
        /// Draws the pause menu screen. This darkens down the gameplay screen
        /// that is underneath us, and then chains to the base MenuScreen.Draw.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 2 / 3);

            base.Draw(gameTime);
        }
Example #4
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // Clear screen
            ScreenManager.GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();

            // Draw munchies
            for (int i = 0; i < noOfMunchies; i++)
            {
                if (munchieAnimationCount[i] == 0)
                {
                    // Draw frame 1
                    spriteBatch.Draw(munchie1, munchiePos[i], Color.White);
                }
                else
                {
                    // Draw frame 2
                    spriteBatch.Draw(munchie2, munchiePos[i], Color.White);
                }
            }
            // Draw enemy
            for (int i = 0; i < enemyCount; i++)
            {
                if (enemyAnimationCount[i] == 0)
                {
                    // Draw frame 1
                    spriteBatch.Draw(enemy1, enemyPos[i], Color.White);
                }
                else
                {
                    // Draw frame 2
                    spriteBatch.Draw(enemy2, enemyPos[i], Color.White);
                }
            }

            // Draw Pacman
            {
                spriteBatch.Draw(pacman, pacmanPos,
                                 new Rectangle(currentFrame.X * frameSize.X,
                                               currentFrame.Y * frameSize.Y,
                                               frameSize.X,
                                               frameSize.Y),
                                 Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0);
            }
            // draw scores & lives
            {
                spriteBatch.DrawString(highscoreFont, "Score: " + score,
                                       new Vector2(10, 10), Color.GreenYellow, 0, Vector2.Zero, 1, SpriteEffects.None, 1);

                spriteBatch.DrawString(livesFont, "Lives: " + lives,
                                       new Vector2(100, 10), Color.GreenYellow, 0, Vector2.Zero, 1, SpriteEffects.None, 1);

                spriteBatch.End();
            }
            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0)
            {
                ScreenManager.FadeBackBufferToBlack(255 - TransitionAlpha);
            }
        }
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);
            ScreenManager.GraphicsDevice.Textures[1] = waterfallTexture;
            refractionEffect.Parameters["DisplacementScroll"].SetValue(Functions.MoveInCircle(gameTime, 0.2f));
            refractionEffect.Begin();
            refractionEffect.CurrentTechnique.Passes[0].Begin();

            // Draw the background first, covers the entire viewport
            spriteBatch.Draw(gameBackground, Vector2.Zero, Color.White);

            #region Draw power-up
            if (powerUp.IsActive)
            {
                spriteBatch.Draw(blank,
                                 powerUp.Position,
                                 powerUp.Rectangle,
                                 powerUp.Color,
                                 0, new Vector2(30, 10), 1,
                                 SpriteEffects.None,
                                 0);
                spriteBatch.DrawString(powerUpFont, powerUp.DisplayName, powerUp.Position - new Vector2(29, 11), new Color(Color.Black, 175));
            }
            #endregion

            #region Draw blood effects
            foreach (Blood b in blood)
            {
                if (b.IsActive)
                {
                    spriteBatch.Draw(b.Texture, b.Position,
                                     new Rectangle(b.CurrentFrame.X * b.FrameSize.X,
                                                   b.CurrentFrame.Y * b.FrameSize.Y,
                                                   b.FrameSize.X,
                                                   b.FrameSize.Y),
                                     b.Color, b.Rotation, b.Origin, b.Scale, b.SpriteEffects, 0);
                }
            }
            #endregion

            #region Draw fish
            foreach (Fish f in fish)
            {
                if (f.IsActive)
                {
                    spriteBatch.Draw(f.Texture, f.Position,
                                     new Rectangle(f.CurrentFrame.X * f.FrameSize.X,
                                                   f.CurrentFrame.Y * f.FrameSize.Y,
                                                   f.FrameSize.X,
                                                   f.FrameSize.Y),
                                     f.Color, f.Rotation, f.Origin, f.Scale, f.SpriteEffects, 0);
                }
            }
            #endregion

            #region Draw piranha
            if (piranha.IsActive)
            {
                spriteBatch.Draw(piranha.Texture, piranha.Position,
                                 new Rectangle(piranha.CurrentFrame.X * piranha.FrameSize.X,
                                               piranha.CurrentFrame.Y * piranha.FrameSize.Y,
                                               piranha.FrameSize.X,
                                               piranha.FrameSize.Y),
                                 piranha.Color, piranha.Rotation, piranha.Origin, piranha.Scale, piranha.SpriteEffects, 0);
            }
            #endregion

            #region Draw mines
            foreach (Mine mine in mines)
            {
                if (mine.IsActive)
                {
                    spriteBatch.Draw(mine.Texture, mine.Position,
                                     new Rectangle(mine.CurrentFrame.X * mine.FrameSize.X,
                                                   mine.CurrentFrame.Y * mine.FrameSize.Y,
                                                   mine.FrameSize.X,
                                                   mine.FrameSize.Y),
                                     mine.Color, mine.Rotation, mine.Origin, mine.Scale, mine.SpriteEffects, 0);
                }
            }
            #endregion

            spriteBatch.Draw(fog, Vector2.Zero, new Color(Color.SteelBlue, 100));

            spriteBatch.End();
            refractionEffect.CurrentTechnique.Passes[0].End();
            refractionEffect.End();
            spriteBatch.Begin();

            #region Draw UI
            if (powerUp.Running)
            {
                spriteBatch.Draw(blank, new Rectangle(10, 10, 210, 30), new Color(Color.Black, 100));
                int left = (powerUp.EffectEnd - DateTime.Now).Seconds;
                spriteBatch.Draw(blank, new Rectangle(15, 15, left * 10, 20), new Color(Color.LightBlue, 120));
            }

            spriteBatch.Draw(blank, new Rectangle(Functions.GameSize.X - 220, 10, 210, 30), new Color(Color.Black, 100));
            spriteBatch.Draw(blank, new Rectangle(Functions.GameSize.X - 215, 15, piranha.Health * 2, 20), new Color((piranha.Poisoned) ? Color.GreenYellow : Color.Red, 150));

            spriteBatch.DrawString(spriteFont,
                                   Functions.Alert.Message,
                                   new Vector2((Functions.GameSize.X / 2) - (spriteFont.MeasureString(Functions.Alert.Message).X / 2), 15),
                                   Functions.Alert.Color);
            #endregion

            spriteBatch.End();

            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0)
            {
                ScreenManager.FadeBackBufferToBlack(255 - TransitionAlpha);
            }
        }
        /// <summary>
        /// This is called when the movie should draw itself.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            float transitionOffset = (float)Math.Pow(TransitionPosition, 2);

            spriteBatch.Begin();

            spriteBatch.Draw(background, Vector2.Zero, Color.White);

            // Draw a black, semi-transparent, background to see the text better
            spriteBatch.Draw(blank, new Rectangle(10, 140, 582, 285), new Color(Color.Black, 100));

            #region Draw Title
            // Draw the menu title.
            Vector2 titlePosition = new Vector2(426, 80);
            Vector2 titleOrigin   = font.MeasureString(menuTitle) / 2;
            //Color titleColor = new Color(192, 192, 192, TransitionAlpha);
            Color titleColor = Color.LightCyan;
            float titleScale = 1.25f;

            titlePosition.Y -= transitionOffset * 100;

            spriteBatch.DrawString(font, menuTitle, titlePosition, titleColor, 0,
                                   titleOrigin, titleScale, SpriteEffects.None, 0);

            #endregion

            spriteBatch.DrawString(smallfont, "The aim of the game is simple: eat the fish and avoid the mines", new Vector2(20, 150), Color.White);

            spriteBatch.DrawString(smallfont, "Gray mines will cause instant damage", new Vector2(20, 165), Color.Tomato);
            spriteBatch.DrawString(smallfont, "Yellow/Green mines will poison you. Poison will cause damage over time.", new Vector2(20, 180), Color.YellowGreen);
            spriteBatch.DrawString(smallfont, "When you are poisoned, one fish will turn green. You must eat this fish to be cured.", new Vector2(40, 195), Color.YellowGreen);

            spriteBatch.DrawString(smallfont, "Power-Ups: these can be eaten to provide different beneficial effects", new Vector2(20, 225), Color.White);

            Vector2 puPos = new Vector2(50, 230);
            foreach (PowerUp pu in powerUps)
            {
                puPos += new Vector2(0, 25);
                spriteBatch.Draw(blank,
                                 puPos,
                                 pu.Rectangle,
                                 pu.Color,
                                 0, new Vector2(30, 10), 1,
                                 SpriteEffects.None,
                                 0);
                spriteBatch.DrawString(smallfont, pu.DisplayName, puPos - new Vector2(29, 11), new Color(Color.Black, 175));
            }

            spriteBatch.DrawString(smallfont, "Health +5", new Vector2(87, 248), Color.LightGreen);
            spriteBatch.DrawString(smallfont, "Health +10", new Vector2(87, 273), Color.LightGreen);
            spriteBatch.DrawString(smallfont, "Health +25", new Vector2(87, 298), Color.LightGreen);
            spriteBatch.DrawString(smallfont, "No Chase - while active, mines won't chase you when you get close.", new Vector2(87, 323), Color.LightSkyBlue);
            spriteBatch.DrawString(smallfont, "Repel - while active, mines will move away from you.", new Vector2(87, 348), Color.LightPink);
            spriteBatch.DrawString(smallfont, "Slow Fish - while active, fish will move slower.", new Vector2(87, 373), Color.Yellow);
            spriteBatch.DrawString(smallfont, "Slow Mines - while active, mines will move slower.", new Vector2(87, 398), Color.Salmon);

            spriteBatch.End();

            // If the screen is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0)
            {
                ScreenManager.FadeBackBufferToBlack(255 - TransitionAlpha);
            }
        }