FadeBackBufferToBlack() public method

Helper draws a translucent black fullscreen sprite, used for fading screens in and out, and for darkening the background behind popups.
public FadeBackBufferToBlack ( float alpha ) : void
alpha float
return void
コード例 #1
0
        /// <summary>
        /// Draws the gameplay screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            ScreenManager.GraphicsDevice.Clear(ClearOptions.Target, Color.Black, 0, 0);

            this.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);

            this.spriteBatch.Draw(this.background, new Rectangle(0, 0, MainGame.ScreenWidth, MainGame.ScreenHeight), Color.White);

            foreach (GameObject gameObject in this.gameObjects)
            {
                gameObject.Draw(this.spriteBatch);
            }

            this.spriteBatch.End();

            UserInterface.Active.Draw(spriteBatch);

            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0 || pauseAlpha > 0)
            {
                float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2);

                ScreenManager.FadeBackBufferToBlack(alpha);
            }
        }
コード例 #2
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 = 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, message, textPosition, color);

            spriteBatch.End();
        }
コード例 #3
0
        /// <summary>
        /// Draws the gameplay screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            spriteBatch.Begin();
            //piirretään nörtti ja tausta.. tähän voisi vääntää sellaisen systeemin että pistetään kaikki piirrettävät systeemit listaan ja iteroidaan niille piirtofunktio
            mBackgroundOne.Draw(spriteBatch);
            nerd.Draw(spriteBatch);


            //  spriteBatch.DrawString(gameFont, "// TODO", playerPosition, Color.Green);

            //   spriteBatch.DrawString(gameFont, "Insert Gameplay Here", enemyPosition, Color.DarkRed);

            spriteBatch.End();



            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0 || pauseAlpha > 0)
            {
                float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2);

                ScreenManager.FadeBackBufferToBlack(alpha);
            }
        }
コード例 #4
0
        /// <summary>
        /// Draws the gameplay screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // This game has a blue background. Why? Because!
            ScreenManager.GraphicsDevice.Clear(ClearOptions.Target,
                                               Color.CornflowerBlue, 0, 0);

            // Our player and enemy are both actually just text strings.
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            spriteBatch.Begin();

            spriteBatch.DrawString(gameFont, "// TODO", playerPosition, Color.Green);

            spriteBatch.DrawString(gameFont, "Insert Gameplay Here",
                                   enemyPosition, Color.DarkRed);

            spriteBatch.End();

            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0 || pauseAlpha > 0)
            {
                float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2);

                ScreenManager.FadeBackBufferToBlack(alpha);
            }
        }
コード例 #5
0
        /// <summary>
        ///   Draws the gameplay screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            ScreenManager.GraphicsDevice.Clear(ClearOptions.Target,
                                               Color.CornflowerBlue, 0, 0);

            // Our player and enemy are both actually just text strings.
            var spriteBatch = ScreenManager.SpriteBatch;

            spriteBatch.Begin();

            // Draw chess map
            DrawChessBoard(ref spriteBatch);
            // Draw mouse position
            spriteBatch.DrawString(_gameFont,
                                   new StringBuilder(string.Format("Mouse position: {0}:{1}", _mousePoint.X,
                                                                   _mousePoint.Y)), new Vector2(300), Color.White);

            spriteBatch.End();

            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0 || _pauseAlpha > 0)
            {
                var alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, _pauseAlpha / 2);

                ScreenManager.FadeBackBufferToBlack(alpha);
            }
        }
コード例 #6
0
        public override void Draw(GameTime gameTime)
        {
            ScreenManager.Game.GraphicsDevice.Clear(new Color(37, 59, 89));

            skyBGParallax.Draw(ScreenManager.SpriteBatch, 90);
            waterParallax.Draw(ScreenManager.SpriteBatch, false, 90);
            cloudsParallax.Draw(ScreenManager.SpriteBatch, true, 90);

            ScreenManager.SpriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null);
            //ScreenManager.SpriteBatch.Draw(ScreenManager.blankTexture, new Rectangle(0,0,ScreenManager.Game.RenderWidth,ScreenManager.Game.RenderHeight), null, new Color(200,0,0));
            ScreenManager.SpriteBatch.Draw(texLogo, new Vector2(ScreenManager.Game.RenderWidth / 2, (ScreenManager.Game.RenderHeight / 2) - 40), new Rectangle(0, 0, 195, 65), Color.White, 0f, new Vector2(98, 32), 1f, SpriteEffects.None, 0);

            ScreenManager.SpriteBatch.End();

            ScreenManager.SpriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null);
            string fluff = "@garethiw and @gredgie for LD29";

            ScreenManager.SpriteBatch.DrawString(ScreenManager.FontSmall, fluff, new Vector2(ScreenManager.Game.RenderWidth / 2, ScreenManager.Game.RenderHeight - 30) + Vector2.One, Color.Black, 0f, ScreenManager.FontSmall.MeasureString(fluff) / 2, 1f, SpriteEffects.None, 0);
            ScreenManager.SpriteBatch.DrawString(ScreenManager.FontSmall, fluff, new Vector2(ScreenManager.Game.RenderWidth / 2, ScreenManager.Game.RenderHeight - 30), Color.DarkGray, 0f, ScreenManager.FontSmall.MeasureString(fluff) / 2, 1f, SpriteEffects.None, 0);
            fluff = "WASD/Arrows, X/Space or 360 pad";
            ScreenManager.SpriteBatch.DrawString(ScreenManager.FontSmall, fluff, new Vector2(ScreenManager.Game.RenderWidth / 2, ScreenManager.Game.RenderHeight - 22) + Vector2.One, Color.Black, 0f, ScreenManager.FontSmall.MeasureString(fluff) / 2, 1f, SpriteEffects.None, 0);
            ScreenManager.SpriteBatch.DrawString(ScreenManager.FontSmall, fluff, new Vector2(ScreenManager.Game.RenderWidth / 2, ScreenManager.Game.RenderHeight - 22), Color.DarkGray, 0f, ScreenManager.FontSmall.MeasureString(fluff) / 2, 1f, SpriteEffects.None, 0);
            ScreenManager.SpriteBatch.End();

            cloudsParallax.Draw(ScreenManager.SpriteBatch, false, 90);
            waterParallax.Draw(ScreenManager.SpriteBatch, true, 90);

            ScreenManager.FadeBackBufferToBlack(1f - TransitionAlpha);

            base.Draw(gameTime);
        }
コード例 #7
0
        /// <summary>
        /// Draws the message box.
        /// </summary>
        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 * 2 / 3);

            // Center the 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;

            // Fade the popup alpha during transitions.
            Color color = new Color(
                (byte)r.Next(0, 255),
                (byte)r.Next(0, 255),
                (byte)r.Next(0, 255));

            color = color * TransitionAlpha;

            spriteBatch.Begin();

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

            spriteBatch.End();
        }
コード例 #8
0
        public override void Draw(GameTime gameTime)
        {
            ScreenManager.FadeBackBufferToBlack(0.3f * TransitionAlpha);

            ScreenManager.SpriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null);
            ScreenManager.SpriteBatch.Draw(text, new Vector2(ScreenManager.Game.RenderWidth / 2, (ScreenManager.Game.RenderHeight / 2) - 20), new Rectangle(293, 35, 103, 31), Color.White, 0f, new Vector2(51, 15), new Vector2(1f + TransitionPosition, 1f - TransitionPosition), SpriteEffects.None, 0);
            ScreenManager.SpriteBatch.End();

            base.Draw(gameTime);
        }
コード例 #9
0
        /// <summary>
        /// Draws the gameplay screen
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // Define new sprite batch
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            // Begin drawing
            spriteBatch.Begin();

            // Draw the background
            spriteBatch.Draw(backgroundTexture, fullscreenRec, new Color(TransitionAlpha, TransitionAlpha, TransitionAlpha));

            // Iterate over every move in our XML
            for (int i = 0; i < moveNode.ChildNodes.Count; i++)
            {
                // Check to see if our player satisfies the win requirements for the move
                if (int.Parse(move.GetElementsByTagName("Wins")[i].InnerText) <= PlayerInfo.Wins)
                {
                    // Define new strings that we append or preface our final text display with depending on whether or not the move is selected or equipped
                    string first = "";
                    string last  = "";

                    // Check to see if the current move is selected
                    if (i == selectedMove)
                    {
                        // Add a < sign to denote that the player is on this move
                        last = "<";
                    }
                    // Check to see if the move is in the player's equipped moves
                    if (PlayerInfo.Moves.Contains(i))
                    {
                        // Add a > sign to denote that the player has this move equipped
                        first = ">";
                    }

                    // Draw out the move and whether or not it is selected/equipped.
                    spriteBatch.DrawString(gameFont, $"{first + move.ChildNodes[i].Name + last}", new Vector2(30, 30 + 30 * i), Color.DarkRed);
                }
            }

            // Draw out the currently equipped move information (type, amount, chance, and description)
            spriteBatch.DrawString(gameFont, $"Type: {move.GetElementsByTagName("Type")[selectedMove].InnerText}", new Vector2(30, 300), Color.White);
            spriteBatch.DrawString(gameFont, $"Amount: {move.GetElementsByTagName("Range")[selectedMove].InnerText}", new Vector2(30, 330), Color.White);
            spriteBatch.DrawString(gameFont, $"Chance: {move.GetElementsByTagName("Chance")[selectedMove].InnerText}", new Vector2(30, 360), Color.White);
            spriteBatch.DrawString(gameFont, $"{move.GetElementsByTagName("Description")[selectedMove].InnerText}", new Vector2(30, 390), Color.White);

            spriteBatch.End();

            // If the game is transitioning on or off, fade it out to black
            if (TransitionPosition > 0 || pauseAlpha > 0)
            {
                float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2);
                ScreenManager.FadeBackBufferToBlack(alpha);
            }
        }
コード例 #10
0
        /// <summary>
        /// Draws the gameplay screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // This game has a blue background. Why? Because!
            //ScreenManager.GraphicsDevice.Clear(ClearOptions.Target,
            //                                 /*Color.CornflowerBlue*/
            //                               Color.Black, 0, 0);

            // Our player and enemy are both actually just text strings.
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            spriteBatch.Begin();

            //spriteBatch.DrawString(gameFont, "// TODO", playerPosition, Color.Green);

            /*
             * Color color = new Color(255, 255, 255, 255);
             *
             *
             * int x = (int)playerPosition.X;
             *
             * int i = (x % 20) / 4;
             *
             * Rectangle source = new Rectangle((4-i)*24, (lastMove*24), 24, 24);
             *
             * Rectangle monsterRectangle = new Rectangle((int)playerPosition.X, (int)playerPosition.Y, 48, 48);
             *
             * spriteBatch.Draw(sprite, monsterRectangle, source, color);
             */
            gameObjectManager.Draw(gameTime);

            /*
             * for (int i = 0; i <= 24; i++)
             * {
             *  for (int j = 0; j <= 18; j++)
             *  {
             *      spriteBatch.Draw(sprite, new Vector2(i * 24, j * 24), new Rectangle(450, 40, 1, 1), new Color(255, 255, 255, 255));
             *  }
             * }
             */

            //spriteBatch.DrawString(gameFont, "Insert Gameplay Here", enemyPosition, Color.DarkRed);

            spriteBatch.End();

            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0)
            {
                ScreenManager.FadeBackBufferToBlack(255 - TransitionAlpha);
            }
        }
コード例 #11
0
        /// <summary>
        /// Draws the gameplay screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            ScreenManager.GraphicsDevice.Clear(ClearOptions.Target, Color.Black, 0, 0);

            // Our player and enemy are both actually just text strings.
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            spriteBatch.Begin();

            if (!componentManager.portalActive)
            {
                int i, n;
                for (i = 0; i < 3; i++)
                {
                    for (n = 0; n < 3; n++)
                    {
                        spriteBatch.Draw(bgTexture, new Vector2(i * 512, n * 512), Color.White);
                    }
                }
            }

            player.Draw(spriteBatch);
            componentManager.Draw(spriteBatch, player);

            spriteBatch.DrawString(gameFont, string.Format("Level {0}", componentManager.level), new Vector2(20, 20), Color.White);
            spriteBatch.DrawString(gameFont, string.Format("Efficiency: {0}%", Math.Round(componentManager.kills / componentManager.shotsTaken * 100)), new Vector2(20, 60), Color.White);

            //spriteBatch.DrawString(gameFont, "// TODO", playerPosition, Color.Green);

            //spriteBatch.DrawString(gameFont, "Insert Gameplay Here",
            //enemyPosition, Color.DarkRed);

            spriteBatch.DrawString(gameFont, string.Format("Health: {0}", player.health), new Vector2(ScreenManager.windowSize.X - 200, 20), Color.White);
            spriteBatch.DrawString(gameFont, string.Format("Core Health: {0}", componentManager.core.health), new Vector2(ScreenManager.windowSize.X - 260, 60), Color.White);

            if (componentManager.gameOver)
            {
                spriteBatch.DrawString(gameFont, "Game Over", new Vector2(ScreenManager.windowSize.X / 2 - 80, ScreenManager.windowSize.Y / 2 - 40), Color.White);
            }

            spriteBatch.End();

            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0 || pauseAlpha > 0)
            {
                float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2);

                ScreenManager.FadeBackBufferToBlack(alpha);
            }
        }
コード例 #12
0
        public override void Draw(GameTime gameTime)
        {
            BoundingFrustum viewFrustum      = camera.ViewFrustum;
            BoundingFrustum lightViewFrustum = level.Light.ViewFrustum;

            level.SortMeshList(camera.Position, viewFrustum);

            graphicsDevice.DepthStencilState = DepthStencilState.Default;

            // Draw occlusion
            //DrawOcclusions(viewFrustum);

            // Draw shadows
            DrawShadows(lightViewFrustum);

            // Draw reflections
            DrawReflections(viewFrustum);

            // Draw main
            DrawMain(viewFrustum);

            // Draw SpriteBatch data
            spriteBatch.Begin();

            if (!postProcessingEffectsEnabled)
            {
                // Draw the frame
                graphicsDevice.SetRenderTarget(null);
                spriteBatch.Draw(mainRT, new Rectangle(0, 0, screenWidth, screenHeight), Color.White);
            }

            if (displayFPS)
            {
                spriteBatch.DrawString(font, fps.ToString(),
                                       new Vector2(screenWidth * 0.05f, screenHeight * 0.05f), Color.Yellow);
            }

            spriteBatch.End();

            CalcFPS(gameTime);

            // If the game is transitioning on or off, fade it out to black.
            if (base.TransitionPosition > 0.0f)
            {
                ScreenManager.FadeBackBufferToBlack(1.0f - TransitionAlpha);
            }
        }
コード例 #13
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  acceptSize     = font.MeasureString(acceptMessage);
            Vector2  declineSize    = font.MeasureString(declineMessage);
            Vector2  textPosition   = (viewportSize - textSize) / 2;
            Vector2  acceptPosition = textPosition +
                                      new Vector2((textSize.X / 4) - (acceptSize.X / 2),
                                                  (textSize.Y * 1.1f));
            Vector2 declinePosition = textPosition +
                                      new Vector2((textSize.X * 0.75f) - (declineSize.X / 2),
                                                  (textSize.Y * 1.1f));

            // 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 + (int)acceptSize.Y + vPad * 2);

            spriteBatch.Begin();

            // Draw the background rectangle.
            spriteBatch.Draw(gradientTexture, backgroundRectangle, Color.White * (TransitionAlpha - 0.2f));

            // Draw the message box text.
            spriteBatch.DrawString(font, message, textPosition, Color.White * TransitionAlpha);
            spriteBatch.DrawString(font, acceptMessage, acceptPosition, Color.White * TransitionAlpha);
            spriteBatch.DrawString(font, declineMessage, declinePosition, Color.White * TransitionAlpha);

            spriteBatch.End();
        }
コード例 #14
0
        /// <summary>
        /// Draws the gameplay screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // This game has a blue background. Why? Because!
            ScreenManager.GraphicsDevice.Clear(ClearOptions.Target,
                                               Color.CornflowerBlue, 0, 0);



            // Our player and enemy are both actually just text strings.
            switch (camera.getCameraState())
            {
            default:
            case 0:
                camera.UpdateCamera(ScreenManager.GraphicsDevice.Viewport);
                break;

            case 1:
                camera.UpdateCameraFirstPerson(ScreenManager.GraphicsDevice.Viewport);
                break;

            case 2:
                camera.UpdateCameraThirdPerson(ScreenManager.GraphicsDevice.Viewport);
                break;
            }
            level.drawLevel();

            drawAvatar();

            hud2.draw();
            //ScreenManager.GraphicsDevice.RenderState.DepthBufferEnable = true; // xna 3 verze
            // ScreenManager.GraphicsDevice.DepthStencilState.DepthBufferEnable = true;

            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0)
            {
                ScreenManager.FadeBackBufferToBlack(255 - TransitionAlpha);
            }
            //base.Draw(gameTime);
        }
コード例 #15
0
        /// <summary>
        /// Draws the gameplay screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // Black Background for the Vid
            ScreenManager.GraphicsDevice.Clear(ClearOptions.Target,
                                               Color.Black, 0, 0);

            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            spriteBatch.Begin();
            if (videoPlayer.State == MediaState.Playing)
            {
                spriteBatch.Draw(videoPlayer.GetTexture(), new Rectangle(0, 0, 800, 600), Color.White);
            }

            spriteBatch.End();
            base.Draw(gameTime);

            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0)
            {
                ScreenManager.FadeBackBufferToBlack(255 - TransitionAlpha);
            }
        }
コード例 #16
0
        /// <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);
        }
コード例 #17
0
        /// <summary>
        /// Draws the message box.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            if (DrawContorno)
            {
                SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

                // Fix for Silversprite
                spriteBatch.Begin();
                spriteBatch.End();

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

                spriteBatch.Begin();

                var font = ScreenManager.Font;

#if SILVERLIGHT
                Color colorBack = new Color(Color.White, TransitionAlpha);
#else
                Color colorBack = Color.White * TransitionAlpha;
#endif

#if SILVERLIGHT
                Color colorText = new Color(Color.Black, TransitionAlpha);
#else
                Color colorText = Color.Black * TransitionAlpha;
#endif

                if (!string.IsNullOrEmpty(Message))
                {
                    var backgroundRectangle = new Rectangle((int)TextPosition.X - HPad,
                                                            (int)TextPosition.Y - VPad,
                                                            (int)TextSize.X + HPad * 2,
                                                            (int)TextSize.Y + VPad * 2);
                    // Draw the background rectangle.
                    spriteBatch.Draw(GradientTexture, backgroundRectangle, colorBack);


                    // Draw the message box text.
                    spriteBatch.DrawWrappedStringWidth(font, Message, TextPosition, colorText, 0, Vector2.Zero, Scale, SpriteEffects.None, 0, ScreenManager.GraphicsDevice.Viewport.Width, out TextSize);
                }

                const int hPad = HPad / 2;
                const int vPad = VPad / 2;

                // Draw the message box text background rectangle.
                var rect = new Rectangle((int)OkMenuEntry.Position.X - hPad,
                                         (int)OkMenuEntry.Position.Y - vPad,
                                         OkMenuEntry.GetWidth(this) + hPad * 2,
                                         OkMenuEntry.GetHeight(this) + vPad * 2);
                spriteBatch.Draw(GradientTexture, rect, colorBack);

                if (CancelMenuEntry != null)
                {
                    // Draw the message box text background rectangle.
                    rect = new Rectangle((int)CancelMenuEntry.Position.X - hPad,
                                         (int)CancelMenuEntry.Position.Y - vPad,
                                         CancelMenuEntry.GetWidth(this) + hPad * 2,
                                         CancelMenuEntry.GetHeight(this) + vPad * 2);
                    spriteBatch.Draw(GradientTexture, rect, colorBack);
                }

                spriteBatch.End();
            }

            base.Draw(gameTime);
        }
コード例 #18
0
        /// <summary>
        /// Draws the gameplay screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // This game has a blue background. Why? Because!
            ScreenManager.GraphicsDevice.Clear(ClearOptions.Target,
                                               Color.Black, 0, 0);

            // Our player and enemy are both actually just text strings.
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            spriteBatch.Begin();

            //spriteBatch.DrawString(gameFont, "// TODO", playerPosition, Color.Green);

            //spriteBatch.DrawString(gameFont, "Insert Gameplay Here",
            //                       enemyPosition, Color.DarkRed);


            /////My stuff



            foreach (GameObject w in player1.weapon1)
            {
                if (w.isAlive)
                {
                    spriteBatch.Draw(w.texture, w.position, Color.White);
                }
            }


            //enemies
            foreach (EnemyObject e in enemies1)
            {
                if (e.isAlive)
                {
                    spriteBatch.Draw(e.texture, e.position, Color.White);
                }
            }


            if (player1.isAlive)
            {
                player1.Draw(spriteBatch);
                spriteBatch.DrawString(gameFont, player1.score.ToString(), new Vector2(400, 0), Color.Green);
            }
            else
            {
                spriteBatch.DrawString(gameFont, player1.score.ToString(), new Vector2(400, 0), Color.Green);
                spriteBatch.DrawString(GameOverFont, "Game Over", new Vector2(100, 300), Color.Red);

                //Thread.Sleep(2000);
                //  LoadingScreen.Load(ScreenManager, false, ControllingPlayer, new BackgroundScreen(), new MainMenuScreen());
            }

            spriteBatch.End();

            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0)
            {
                ScreenManager.FadeBackBufferToBlack(1f - TransitionAlpha);
            }
        }
コード例 #19
0
        /// <summary>
        /// Draws the gameplay screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // This game has a blue background. Why? Because!
            ScreenManager.GraphicsDevice.Clear(ClearOptions.Target,
                                               Color.CornflowerBlue, 0, 0);

            // Our player and enemy are both actually just text strings.
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
            Viewport    viewport    = ScreenManager.GraphicsDevice.Viewport;
            Rectangle   fullscreen  = new Rectangle(0, 0, viewport.Width, viewport.Height);



            spriteBatch.Begin();



            //spriteBatch.Draw(backgroundStart, fullscreen, new Color(TransitionAlpha, TransitionAlpha, TransitionAlpha));

            //spriteBatch.DrawString(gameFont, "// TODO", playerPosition, Color.Green);
            //draw new paralaxing background
            //spriteBatch.Draw(mainBackground, Vector2.Zero, Color.White);
            //  star1.Draw(spriteBatch);
            //  star2.Draw(spriteBatch);
            //dont draw these for now
            // bgLayer1.Draw(spriteBatch);
            // bgLayer2.Draw(spriteBatch);
            //draw the score
            //draw sroller

            newBackground.Draw(spriteBatch);

            // spriteBatch.DrawString(scoreFont, "score: " + player.Score, new Vector2(ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.X, ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y), Color.White);

            spriteBatch.DrawString(scoreFont, "score:" + player.Score, scorePosition, Color.White);
            spriteBatch.DrawString(scoreFont, "Health: " + player.Health, new Vector2(ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.X, ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y + 35), Color.White);

            spriteBatch.DrawString(scoreFont, "Lives: " + iLivesLeft, new Vector2(ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.X, ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y + 70), Color.White);

            spriteBatch.DrawString(scoreFont, "Shield: " + player.Shield, new Vector2(ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.X, ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y + 100), Color.White);

            spriteBatch.DrawString(scoreFont, "Damage: + " + player.DamageMod, new Vector2(ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.X, ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y + 130), Color.White);
            //draw asteroids
            foreach (AsteroidEnemy2 asteroid in asteroids2)
            {
                asteroid.Draw(spriteBatch);
            }
            //for (int i = 0; i < asteroids2.Count; i++)
            //{
            //    asteroids2[i].Draw(spriteBatch);
            //}

            //draw the enemies

            foreach (Enemy enemy in enemies)
            {
                enemy.Draw(spriteBatch);
            }
            //for (int i = 0; i < enemies.Count; i++)
            //{
            //    enemies[i].Draw(spriteBatch);

            //}

            //draw balloon enemies
            foreach (GreenMineEnemy balloonenemy in balloonEnemies)
            {
                balloonenemy.Draw(spriteBatch);
            }
            //for (int i = 0; i < balloonEnemies.Count; i++)
            //{
            //    balloonEnemies[i].Draw(spriteBatch);
            //}


            //working now draw player from player class.

            //player.Draw(spriteBatch);
            //draw fire hair
            foreach (FireHair firehair in fireHairEnemies)
            {
                firehair.Draw(spriteBatch);
            }

            //draw projectiles
            foreach (Projectile projectile in projectiles)
            {
                projectile.Draw(spriteBatch);
            }
            //for (int i = 0; i < projectiles.Count; i++)
            //{
            //    projectiles[i].Draw(spriteBatch);
            //}

            //draw explosions
            foreach (Animation explosion in explosions)
            {
                explosion.Draw(spriteBatch);
            }
            //for (int i = 0; i < explosions.Count; i++)
            //{
            //    explosions[i].Draw(spriteBatch);
            //}

            //draw damage powerup  //changed to foreachloop
            foreach (PowerUp damagepowerup in damagePowerUps)
            {
                damagepowerup.Draw(spriteBatch);
            }
            //for (int i = 0; i < damagePowerUps.Count; i++)
            //{
            //    damagePowerUps[i].Draw(spriteBatch);
            //}
            //draw shield powerup //changed to foreach loop
            foreach (PowerUp shieldpowerup in shieldPowerUps)
            {
                shieldpowerup.Draw(spriteBatch);
            }
            //for (int i = 0; i < shieldPowerUps.Count; i++)
            //{
            //    shieldPowerUps[i].Draw(spriteBatch);
            //}



            //todo testing
            if (iLivesLeft == 0)
            {
                spriteBatch.DrawString(gameFont, "G A M E  O V E R", new Vector2(ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.X, ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y + 45), Color.Red);
            }
            //spriteBatch.Draw(playerTexture, playerPosition, Color.White);
            // spriteBatch.DrawString(gameFont, "Insert Gameplay Here",
            //                     enemyPosition, Color.DarkRed);

            spriteBatch.End();


            //draw player and have effects on it as well. ?

            //effect is off as it is not working right now.
            spriteBatch.Begin();
            //spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, standardEffect);
            //todo
            //make a technique to glow eventually when shield is up
            //todo
            //working so far if shield on do the effect on player. just desaturate for now



            if (player.Active)
            {
                player.Draw(spriteBatch);
            }



            spriteBatch.End();


            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0 || pauseAlpha > 0)
            {
                float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2);

                ScreenManager.FadeBackBufferToBlack(alpha);
            }
        }
コード例 #20
0
        /// <summary>
        /// Draws the gameplay screen
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // Define the sprite batch
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            // Begin drawing
            spriteBatch.Begin();

            // Draw the background and move select background
            spriteBatch.Draw(backgroundImg, fullScreenRec, Color.White);
            spriteBatch.Draw(moveSelectImg, fullScreenRec, Color.White);

            // Draw the enemy and player sprites
            enemySpriteManager.Animations[enemySpriteManager.CurrentAnimation].Draw(spriteBatch, Color.White, Animation.FLIP_NONE);
            playerSpriteManager.Animations[playerSpriteManager.CurrentAnimation].Draw(spriteBatch, Color.White, Animation.FLIP_NONE);

            // Store the actual text of the last move to use in calculating the offset
            string lastMoveText = "";

            // Iterate over each of the moves the player has
            foreach (string move in player.MoveNames)
            {
                // Save the string to be prefixed with a > if it is selected
                string first = "";

                // Declare the offset and counter-offset for the text
                Vector2 offset        = new Vector2(0, 0);
                int     counterOffset = 10;

                // Check to see if the current move is the selected move
                if (player.MoveNames.IndexOf(move) == selectedMove)
                {
                    // Set the first string to > to indicate that it is selected
                    first = ">";

                    // Define the horizontal offset and add the counter-offset to push the string back marginally farther
                    offset    = gameFont.MeasureString(first);
                    offset.X -= counterOffset;
                }

                // Draw the string
                spriteBatch.DrawString(gameFont, $"{first + move}", new Vector2(180 + (gameFont.MeasureString(lastMoveText).X) - offset.X, 385), Color.White);

                // Add the last moves full text for calculating the offset for the next move
                lastMoveText += " " + move;
            }

            // Update the player's current move information
            player.UpdateMove(PlayerInfo.Moves[selectedMove]);

            // Draw the selected move information
            spriteBatch.DrawString(smallFont, $"{player.Type}: {player.ValueRange[0]}-{player.ValueRange[1]} damage. {player.Chance}% chance to hit.", new Vector2(155, 345), Color.White);

            // Draw player information
            spriteBatch.DrawString(smallFont, $"Player:", new Vector2(90, 195), Color.White);
            spriteBatch.DrawString(smallFont, $"Health: {player.CurrentHP}", new Vector2(90, 210), Color.White);
            spriteBatch.DrawString(smallFont, $"Damage Taken: {player.DamageReceived}", new Vector2(90, 225), Color.White);
            spriteBatch.DrawString(smallFont, $"Damage Given: {player.DamageGiven}", new Vector2(90, 240), Color.White);
            spriteBatch.DrawString(smallFont, $"Success: {player.MoveSuccessful}", new Vector2(90, 255), Color.White);

            // Draw enemy information
            spriteBatch.DrawString(smallFont, $"Enemy:", new Vector2(650, 195), Color.White);
            spriteBatch.DrawString(smallFont, $"Health: {enemy.CurrentHP}", new Vector2(590, 210), Color.White);
            spriteBatch.DrawString(smallFont, $"Damage Taken: {enemy.DamageReceived}", new Vector2(530, 225), Color.White);
            spriteBatch.DrawString(smallFont, $"Damage Given: {enemy.DamageGiven}", new Vector2(530, 240), Color.White);
            spriteBatch.DrawString(smallFont, $"Success: {enemy.MoveSuccessful}", new Vector2(530, 255), Color.White);

            // Draw score
            spriteBatch.DrawString(gameFont, $"Score: {PlayerInfo.Score}", new Vector2(310, 15), Color.Black);

            // Stop drawing
            spriteBatch.End();

            // If the game is transitioning on or off, fade it out to black
            if (TransitionPosition > 0 || pauseAlpha > 0)
            {
                float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2);

                ScreenManager.FadeBackBufferToBlack(alpha);
            }
        }
コード例 #21
0
        /// <summary>
        /// Draws the gameplay screen
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // Set the background colour to black
            ScreenManager.GraphicsDevice.Clear(ClearOptions.Target, Color.Black, 0, 0);

            // Declare the sprite batch
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            // Begin drawing
            spriteBatch.Begin();

            // Draw the circuit text
            spriteBatch.DrawString(gameFont, "MINOR CIRCUIT", new Vector2(60, 30), Color.Orange);

            // Draw the player's boxing gym info and weight
            spriteBatch.DrawString(gameFont, "FROM", new Vector2(80, 85), Color.White);
            spriteBatch.DrawString(gameFont, "TANGE", new Vector2(90, 105), Color.White);
            spriteBatch.DrawString(gameFont, "BOXING", new Vector2(90, 125), Color.White);
            spriteBatch.DrawString(gameFont, "GYM", new Vector2(90, 145), Color.White);
            spriteBatch.DrawString(gameFont, "WEIGHT: 117", new Vector2(80, 205), Color.White);

            // Draw the player's profile
            spriteBatch.Draw(playerMatchImg, playerProfileRec, Color.White);

            // Draw the player's wins and name
            spriteBatch.DrawString(gameFont, $"{PlayerInfo.Wins} - {PlayerInfo.Losses}  {PlayerInfo.Wins}KO", new Vector2(80, 230), Color.White);
            spriteBatch.DrawString(gameFont, $"JOE YABUKI", new Vector2(80, 400), Color.White);

            // Draw the centre text
            spriteBatch.DrawString(gameFont, "VS.", new Vector2(370, 210), Color.Orange);
            spriteBatch.DrawString(gameFont, "PUSH", new Vector2(355, 350), Color.Orange);
            spriteBatch.DrawString(gameFont, "START!", new Vector2(345, 370), Color.Orange);

            // Draw the enemy ranking
            spriteBatch.DrawString(gameFont, $"RANKED #{enemyInfo.Ranking}", new Vector2(520, 20), Color.LightGreen);

            // Draw the enemy name
            spriteBatch.DrawString(gameFont, $"{enemyInfo.FirstName}", new Vector2(520, 50), Color.White);
            spriteBatch.DrawString(gameFont, $"{enemyInfo.LastName}", new Vector2(535, 75), Color.White);

            // Draw the enemy profile picture and record
            spriteBatch.Draw(enemyMatchImg, enemyProfileRec, Color.White);
            spriteBatch.DrawString(gameFont, $"{enemyInfo.Record}", new Vector2(510, 240), Color.White);

            // Draw the enemy's boxing gym
            spriteBatch.DrawString(gameFont, "FROM", new Vector2(520, 280), Color.White);
            spriteBatch.DrawString(gameFont, $"{enemyInfo.BoxingGym}", new Vector2(530, 300), Color.White);
            spriteBatch.DrawString(gameFont, "BOXING", new Vector2(530, 320), Color.White);
            spriteBatch.DrawString(gameFont, "GYM", new Vector2(530, 340), Color.White);

            // Draw the enemy's weight
            spriteBatch.DrawString(gameFont, $"WEIGHT: {enemyInfo.Weight}", new Vector2(510, 390), Color.White);

            // Stop drawing
            spriteBatch.End();

            // If the game is transitioning on or off, fade it out to black
            if (TransitionPosition > 0 || pauseAlpha > 0)
            {
                float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2);

                ScreenManager.FadeBackBufferToBlack(alpha);
            }
        }