Exemplo n.º 1
0
        protected override void Draw(GameTime gameTime)
        {
            spriteBatch.Begin();

            if (newMapLoad)
            {
                GraphicsDevice.Clear(Color.Black);
                string[] fileName = player1.newMap.Split('.');
                string levelNumber = fileName[0].Remove(0, 13);
                string levelName = String.Format("Level {0}", levelNumber);
                TextField message = new TextField(
                    levelName,
                    new Vector2(
                        (graphics.PreferredBackBufferWidth / 2) - 50,
                        (graphics.PreferredBackBufferHeight / 2) - 50
                    ),
                    Color.White
                    );
                message.loadContent(Content);
                message.draw(spriteBatch);

                float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
                newMapTimer -= elapsed;
                if (newMapTimer < 0)
                {
                    LoadMap(player1.newMap);//Timer expired, execute action
                    newMapTimer = LOAD_SCREEN_TIME;   //Reset Timer
                }
            }
            else
            {
                // Draw background
                spriteBatch.Draw(
                    background,
                    new Rectangle(
                        0, 0,
                        graphics.PreferredBackBufferWidth,
                        graphics.PreferredBackBufferHeight
                    ),
                    Color.White
                );

                // Draw contents of the level
                level.Draw(spriteBatch);

                if (level.message != "")
                {
                    TextField message = new TextField(
                        level.message,
                        new Vector2(16, (graphics.PreferredBackBufferHeight ) - 28),
                        Color.White
                    );

                    message.loadContent(Content);
                    message.draw(spriteBatch);
                }
            }
            spriteBatch.End();
            base.Draw(gameTime);
        }
Exemplo n.º 2
0
        protected override void Draw(GameTime gameTime)
        {
            spriteBatch.Begin();

            if (loadingMap)
            {
                string levelDisplay = player1.newMap.Equals("Win") ? "Congratulations!" :
                    String.Format("Level {0}", player1.newMap);

                GraphicsDevice.Clear(Color.Black);
                TextField message = new TextField(
                    levelDisplay,
                    new Vector2(
                        (graphics.PreferredBackBufferWidth / 2) - 50,
                        (graphics.PreferredBackBufferHeight / 2) - 50
                    ),
                    Color.White
                );
                message.loadContent(Content);
                message.draw(spriteBatch);

            }
            else
            {
                // Draw background
                spriteBatch.Draw(
                    background,
                    new Rectangle(
                        0, 0,
                        graphics.PreferredBackBufferWidth,
                        graphics.PreferredBackBufferHeight
                    ),
                    Color.White
                );

                // Draw intro slides
                if (intro)
                {
                    float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
                    introScreenTimer -= elapsed;
                    spriteBatch.Draw(
                        introImage,
                        new Rectangle(
                        0, 0,
                        720,
                        540
                        ),
                        Color.White
                    );
                    if(introScreenTimer < 0 && slideCount != 5)
                    {
                        slideCount += 1;
                        introImage = Content.Load<Texture2D>(String.Format("Slides/Slide{0}.png", slideCount));
                        introScreenTimer = INTRO_SCREEN_TIME;
                    }
                }

                // Draw contents of the level
                level.Draw(spriteBatch);

                if (paused && !intro)
                {
                    spriteBatch.Draw(

                        pauseScreens[player1.numPowers],
                        new Rectangle(
                        0, graphics.PreferredBackBufferHeight/2 - 270,
                        720,
                        540
                        ),
                        Color.White
                    );
                }

                // Display picked up messages
                if (!String.IsNullOrEmpty(level.message))
                {
                    TextField message = new TextField(
                        level.message,
                        new Vector2(16, (graphics.PreferredBackBufferHeight ) - 28),
                        Color.White
                    );

                    message.loadContent(Content);
                    message.draw(spriteBatch);
                }
            }
            spriteBatch.End();
            base.Draw(gameTime);
        }