Exemple #1
0
 protected override void Draw(GameTime gameTime)
 {
     GraphicsDevice.Clear(Color.Black);
     if (isPlayingVideo)
     {
         spriteBatch.Begin();
         spriteBatch.Draw(videoPlayer.GetTexture(), new Rectangle(0, 0, screenWidth, screenHeight), Color.White);
         spriteBatch.End();
     }
     else
     {
         DateTime start = DateTime.Now;
         stRender.Restart();
         TimeSpan fpsT = start - fpsTime;
         if (fpsT.TotalSeconds >= 1)
         {
             fps        = fpsCounter;
             fpsCounter = 0;
             fpsTime    = start;
         }
         else
         {
             fpsCounter++;
         }
         Render(spriteBatch, gameTime);
         renderTime = stRender.Elapsed;
     }
     base.Draw(gameTime);
 }
Exemple #2
0
        public override void draw(GameTime gameTime)
        {
            if (mVideoPlayer != null)
            {
                if (mVideoPlayer.State != MediaState.Stopped)
                {
                    mVideoTexture = mVideoPlayer.GetTexture();
                }
            }

            if (mVideoTexture != null)
            {
                mSpriteBatch.Begin();
                mSpriteBatch.Draw(mVideoTexture, new Rectangle(0, 0, 800, 600), Color.White);
                mSpriteBatch.End();
            }


            if (mShowTextClickToStart && !mClicked)
            {
                mSpriteBatch.Begin();
                mSpriteBatch.Draw(mTextureClickToStart, new Vector2(280, 520), Color.White);
                mSpriteBatch.End();
            }

            mSpriteBatch.Begin();
            mCursor.draw(mSpriteBatch);

            if (mFade != null)
            {
                mFade.draw(mSpriteBatch);
            }
            mSpriteBatch.End();

            /*mSpriteBatch.Begin(
             *  SpriteSortMode.Immediate,
             *  BlendState.AlphaBlend,
             *  null,
             *  null,
             *  null,
             *  null,
             *  mCamera.get_transformation(Game1.getInstance().GraphicsDevice));
             *
             *
             * if (mCurrentTexture != null)
             * {
             *  mSpriteBatch.Draw(mCurrentTexture, mRectangleExhibitionTexture, Color.White);
             * }
             * //mButtonNext.draw(mSpriteBatch);
             * mCursor.draw(mSpriteBatch);
             *
             * if (mFade != null)
             * {
             *  mFade.draw(mSpriteBatch);
             * }
             *
             *
             * mSpriteBatch.End();
             */
        }
        public void Update(GameTime gameTime)
        {
            if (_core.gameState == Game1.GameState.GameOver)
            {
                if (!isSongPlaying) //Control statement to loop music
                {
                    MediaPlayer.Play(bgMusic);
                    MediaPlayer.Volume      = 0.75f;
                    isSongPlaying           = true;
                    MediaPlayer.IsRepeating = true;
                }
                if (controlInt <= 0)     //Prevent video from playing multiple times
                {
                    vidPlayer.Play(gameOver);
                    controlInt++;

                    //Score formula created by me [check log for formula]
                    finalScore = (int)Math.Round(((_player.PlayerLevel * _player.PlayerLevel) * (_player.maxLevel)) + (_player.PlayerLevel * _player.maxLevel * ((_player.CurrentXP + 1) / _player.XPToNextLevel)) + _player.TotalPlayerMoney, 0);
                }

                vidTexture = vidPlayer.GetTexture();     //Stream video as a series of textures constantly updated, store in vidTexture, draw vidTexture to screen
            }
            else
            {
                isSongPlaying = false;
            }
        }
        /// <summary>
        /// Draws the gameplay screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            ScreenManager.GraphicsDevice.Clear(Color.CornflowerBlue);

            // Only call GetTexture if a video is playing or paused
            if (player.State != MediaState.Stopped)
            {
                videoTexture = player.GetTexture();
            }

            // Drawing to the rectangle will stretch the
            // video to fill the screen
            Rectangle screen = new Rectangle(ScreenManager.GraphicsDevice.Viewport.X,
                                             ScreenManager.GraphicsDevice.Viewport.Y,
                                             ScreenManager.GraphicsDevice.Viewport.Width,
                                             ScreenManager.GraphicsDevice.Viewport.Height);

            // Draw the video, if we have a texture to draw.
            if (videoTexture != null)
            {
                spriteBatch.Begin();
                spriteBatch.Draw(videoTexture, screen, Color.White);
                spriteBatch.End();
            }

            base.Draw(gameTime);
        }
        } // Resume

        #endregion

        #region Update

        /// <summary>
        /// Update.
        /// </summary>
        internal void Update()
        {
            if (videoPlayerInstance != null)
            {
                // If the video ends.
                if (videoPlayerInstance.State == MediaState.Stopped)
                {
                    Stop();
                }
                else
                {
                    videoPlayerInstance.IsMuted  = IsMuted;
                    videoPlayerInstance.IsLooped = IsLooped;
                    videoPlayerInstance.Volume   = Volume;
                    try
                    {
                        texture.Resource = videoPlayerInstance.GetTexture();
                    }
                    catch
                    {
                        // Recreate video player if there is an error. Probably a device disposed.
                        videoPlayerInstance.Dispose();
                        videoPlayerInstance = new VideoPlayer();
                        videoPlayerInstance.Play(Video.Resource);
                        texture.Resource = videoPlayerInstance.GetTexture();
                    }
                }
            }
        } // Update
Exemple #6
0
 public override void Draw(GameTime gameTime)
 {
     _spriteBatch = ScreenManager.SpriteBatch;
     _spriteBatch.Begin();
     _spriteBatch.Draw(_videoPlayer.GetTexture(), new Vector2(100, 100), Color.White);
     _spriteBatch.End();
 }
        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();
            if (index == 1)
            {
                spriteBatch.Draw(ngeeAnnTex, bckgrdRectangle, Color.White);
            }
            else if (index == 2)
            {
                spriteBatch.Draw(titleTex, bckgrdRectangle, Color.White);
            }
            else if (index == 3)
            {
                spriteBatch.Draw(storyTex, bckgrdRectangle, Color.White);
            }
            else if (index == 4)
            {
                // Only call GetTexture if a video is playing or paused
                if (player.State != MediaState.Stopped)
                {
                    videoTexture = player.GetTexture();
                }

                // Draw the video, if we have a texture to draw.
                if (videoTexture != null)
                {
                    spriteBatch.Draw(videoTexture, bckgrdRectangle, Color.White);
                }
            }
            spriteBatch.End();
        }
Exemple #8
0
        private void DrawVideo()
        {
            if (!videoIsGood)
            {
                return;
            }

            if (player == null)
            {
                return;
            }

            if (player.IsDisposed)
            {
                return;
            }

            if (player.State == MediaState.Stopped)
            {
                return;
            }

            videoTexture = player.GetTexture();

            // Drawing to the rectangle will stretch the
            // video to fill the screen


            // Draw the video, if we have a texture to draw.
            if (videoTexture != null)
            {
                Color videoColor = Color.Lerp(OldXNAColor.TransparentWhite, Color.White, vidTransition);
                FrameworkCore.SpriteBatch.Draw(videoTexture, GetVideoRect(), videoColor);
            }
        }
Exemple #9
0
        public override void Draw()
        {
            Globals.spriteBatch.Begin();

            Globals.spriteBatch.Draw(videoPlayer.GetTexture(), new Rectangle(0, 0, (int)Globals.gameSize.X, (int)Globals.gameSize.Y), Color.White);

            Globals.spriteBatch.End();
        }
Exemple #10
0
        public void Draw(SpriteBatch spriteBatch)
        {
            // Sätt programmets textur till videospelarens videoklipp.
            Texture2D texture = videoPlayer.GetTexture();

            spriteBatch.Draw(texture, position, rect, color);
            spriteBatch.DrawString(spriteFont, tileNr, new Vector2(position.X + 70, position.Y + 70), Color.Orange);
        }
Exemple #11
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, new Matrix?(this.camera.viewMatrix));



            gameStates.Draw(gameTime, spriteBatch);

            spriteBatch.End();


            spriteBatch.Begin();

            if (gameStates.isInMenu == true && gameStates.isGame != true)
            {
                if (vidplayer.State != MediaState.Stopped) // Only call GetTexture if a video is playing or paused
                {
                    videoTexture = vidplayer.GetTexture();
                }

                Rectangle screen = new Rectangle(GraphicsDevice.Viewport.X,
                                                 GraphicsDevice.Viewport.Y,
                                                 GraphicsDevice.Viewport.Width,
                                                 GraphicsDevice.Viewport.Height);
                // Drawing to the rectangle will stretch the video to fill the screen

                if (videoTexture != null) // Draw the video, if we have a texture to draw.
                {
                    spriteBatch.Draw(videoTexture, screen, Color.White);
                }
            }
            if (gameStates.isGame)
            {
                healthBar.Draw(spriteBatch);
            }
            gameStates.Draw2(gameTime, spriteBatch);

            spriteBatch.End();
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, camera.viewMatrix);
            if (isloadingLevel == true)
            {
                spriteBatch.Draw(blackScreen, new Vector2(player.m_position.X - 300, player.m_position.Y - 0), Color.White);
                level.info(spriteBatch, gameTime);

                var timer = (float)gameTime.ElapsedGameTime.TotalSeconds;
                level.remainingdelay -= timer;
                if (level.remainingdelay <= 0)
                {
                    isloadingLevel       = false;
                    level.remainingdelay = delay;
                    level.LoadNextMap(Content);
                }
            }
            spriteBatch.End();
            base.Draw(gameTime);
        }
Exemple #12
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.White);
            if (videoPlayer.State != MediaState.Stopped)
            {
                videotexture = videoPlayer.GetTexture();
            }
            //Global.spriteBatch.Begin();
            //if (videotexture != null)
            //    Global.spriteBatch.Draw(videotexture, GraphicsDevice.Viewport.Bounds, Color.White);
            //Global.spriteBatch.End();



            Global.spriteBatch.Begin();
            //Global.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, cam.transform);

            switch (CurrentGameState)
            {
            case GameState.MainMenu:
                Global.spriteBatch.Draw(Content.Load <Texture2D>("imageddsa"), new Rectangle(0, 0, Global.screenwidth, Global.screenheight), Color.White);
                btnPlay.Draw(Global.spriteBatch);
                btnAbout.Draw(Global.spriteBatch);
                btnExit.Draw(Global.spriteBatch);
                break;

            case GameState.Playing:
            {
                Global.spriteBatch.End();
                Global.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, cam.transform);
                GraphicsDevice.Clear(Color.Black);
                gameplay.Draw();
                //Global.spriteBatch.End();
                break;
            }

            case GameState.Options:
                GraphicsDevice.Clear(Color.Gray);

                Global.spriteBatch.Draw(Content.Load <Texture2D>("gioithieu"), new Rectangle(0, 0, Global.screenwidth, Global.screenheight), Color.White);
                btnAboutexit.Draw(Global.spriteBatch);

                break;

            case GameState.IntroVideo:
                if (videotexture != null)
                {
                    Global.spriteBatch.Draw(videotexture, GraphicsDevice.Viewport.Bounds, Color.White);
                }

                break;
            }

            Global.spriteBatch.End();

            base.Draw(gameTime);
        }
 public override void Draw(GameTime gameTime)
 {
     if (isPlaying)
     {
         ScreenManager.SpriteBatch.Begin();
         ScreenManager.SpriteBatch.Draw(player.GetTexture(), Vector2.Zero, Color.White);
         ScreenManager.SpriteBatch.End();
     }
 }
 public override void Draw(GameTime gameTime)
 {
     if (_isPlaying)
     {
         ScreenManager.SpriteBatch.Begin();
         ScreenManager.SpriteBatch.Draw(_player.GetTexture(), Vector2.Zero, Color.White); //Gets current frame of video
         ScreenManager.SpriteBatch.End();
     }
 }
        /// <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(SpriteBatch spriteBatch)
        {
            videotexture = videoplayer.GetTexture();
            // TODO: Add your drawing code here



            spriteBatch.Draw(background, new Rectangle(0, 0, 800, 600), Color.White);
            spriteBatch.Draw(videotexture, videotexturerect, Color.White);
        }
 public override void Update(GameTime gameTime, IActor actor)
 {
     if (videoState == State.Playing)
     {
         SetTexture(videoPlayer.GetTexture(), actor);
     }
     else if (videoState == State.Stopped)
     {
         SetTexture(startTexture, actor);
     }
 }
Exemple #17
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);

            spriteBatch.Begin();
            if (_videoPlayer.State == MediaState.Playing)
            {
                spriteBatch.Draw(_videoPlayer.GetTexture(),
                                 new Rectangle(0, 0, XnaDartsGame.Viewport.Width, XnaDartsGame.Viewport.Height), Color.White);
            }
            spriteBatch.End();
        }
Exemple #18
0
        protected override void OnRender(Nine.Graphics.UI.Renderer.Renderer renderer)
        {
            if (player.State != MediaState.Stopped)
            {
                Texture = player.GetTexture();
            }

            if (Texture != null)
            {
                renderer.Draw(Texture, AbsoluteRenderTransform, null, Color.White, Flip);
            }
        }
Exemple #19
0
 public override void update(GameTime gameTime)
 {
     layer.textura = videoPlayer.GetTexture();
     if (videoPlayer.State == MediaState.Stopped)
     {
         layer.alpha = MathHelper.Lerp(layer.alpha, 0, 0.03f);
         if (layer.alpha < 0.01f)
         {
             SceneManager.setScene(new Menu(), false);
         }
     }
 }
Exemple #20
0
        /// <summary>
        /// Dies wird aufgerufen, wenn das Spiel selbst zeichnen soll.
        /// </summary>
        /// <param name="gameTime">Bietet einen Schnappschuss der Timing-Werte.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Utils.ToColor(mShow.bgColor));

            spriteBatch.Begin();

            if (mShow.currentScene.mSourceEffect != null)
            {
                if (mShow.currentScene.mSourceEffect.id == Utils.VIDEO_ID)
                {
                    if (player.State != MediaState.Stopped)
                    {
                        myTex = player.GetTexture();
                    }
                }
                else if (mShow.currentScene.mSourceEffect.id == Utils.PICTURE_ID)
                {
                    myTex = mImages[Convert.ToInt16(mShow.currentScene.mSourceEffect.source)];
                }

                else if (mShow.currentScene.mSourceEffect.id == Utils.SOUND_FX_ID)
                {
                    myTex = new Texture2D(GraphicsDevice, WIDTH, HEIGHT);
                }
            }

            if (myTex != null)
            {
                if (DEBUG)
                {
                    String debug_txt = mShow.currentScene.name + "- t: " + gameTime.TotalGameTime.Seconds + " - r: " + frameRate;
                    spriteBatch.DrawString(myFont, debug_txt, new Vector2(0, HEIGHT - 25), Color.White);
                    spriteBatch.Draw(myTex, new Rectangle(0, 0, WIDTH, HEIGHT - 25), null, Color.White, 0, new Vector2(), SpriteEffects.None, 1);
                }
                else
                {
                    spriteBatch.Draw(myTex, new Rectangle(0, 0, WIDTH, HEIGHT), null, Color.White, 0, new Vector2(), SpriteEffects.None, 1);
                }
            }

            if (mShow.type == Utils.TIME_CHANGE)
            {
                if (mShow.currentScene.duration + presentationStart < gameTime.TotalGameTime.Hours * 3600 + gameTime.TotalGameTime.Minutes * 60 + gameTime.TotalGameTime.Seconds)
                {
                    presentationStart = gameTime.TotalGameTime.Hours * 3600 + gameTime.TotalGameTime.Minutes * 60 + gameTime.TotalGameTime.Seconds;
                    nextEffect();
                }
            }


            spriteBatch.End();
            base.Draw(gameTime);
        }
Exemple #21
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            spriteBatch.Begin();
            GraphicsDevice.Clear(Color.CornflowerBlue);

            if (currentLevel == null)
            {
                spriteBatch.Draw(vPlayer.GetTexture(), GraphicsDevice.Viewport.Bounds, Color.White);
                Vector2 v1 = new Vector2(150, 300);
                spriteBatch.DrawString(normalText, "No levels to load", v1, Color.White);
            }
            else if (gameState == State.TITLE || currentLevel.loadedState == LoadingState.loading)
            {
                spriteBatch.Draw(vPlayer.GetTexture(), GraphicsDevice.Viewport.Bounds, Color.White);
                if (currentLevel.loadedState == LoadingState.loading)
                {
                    Vector2 v1 = new Vector2(200, 300);
                    spriteBatch.DrawString(normalText, "Loading Level...", v1, Color.White);
                }
                else
                {
                    Vector2 v1        = new Vector2(560, 300);
                    Vector2 StartSize = myStartText.MeasureString("START");
                    spriteBatch.DrawString(myStartText, "START", v1, Color.White, 0f, new Vector2(StartSize.X / 2, StartSize.Y / 2), myStartScale, SpriteEffects.None, 0f);
                }
            }
            else
            {
                // Draw items on current level
                currentLevel.Draw(spriteBatch);
                if (gameState == State.PAUSE)
                {
                    Vector2 v1 = new Vector2(200, 100);
                    spriteBatch.DrawString(normalText, "Game Paused", v1, Color.White);
                }
            }

            spriteBatch.End();
            base.Draw(gameTime);
        }
Exemple #22
0
        public override void start()
        {
            video       = Game1.Self.Content.Load <Video>("VideoIntro");
            videoPlayer = new VideoPlayer();
            videoPlayer.Play(video);
            layer            = new Objeto2D(videoPlayer.GetTexture());
            layer.position.X = Game1.Self.Window.ClientBounds.Width / 2;
            layer.position.Y = Game1.Self.Window.ClientBounds.Height / 2;

            if (SoundManager.isEffectsMuted)
            {
                videoPlayer.Volume = 0;
            }
        }
        private void RenderBackgroundVideo()
        {
            if (_videoPlayer.State == MediaState.Playing)
            {
                _lastVideoTexture = _videoPlayer.GetTexture();
            }

            if (_lastVideoTexture != null)
            {
                SpriteBatch.Begin();
                SpriteBatch.Draw(_lastVideoTexture, _videoTargetRectangle, Color.White);
                SpriteBatch.End();
            }
        }
Exemple #24
0
 public void Draw(SpriteBatch spriteBatch)
 {
     if (videoPlayer.State != MediaState.Stopped)
     {
         Texture2D texture = videoPlayer.GetTexture();
         if (texture != null)
         {
             spriteBatch.Draw(texture, windowAreaRectangle, Color.White);
         }
     }
     else
     {
         animationFinished = true;
     }
 }
Exemple #25
0
        public override void Draw(GameTime gameTime)
        {
            if (videoPlayer.State == MediaState.Playing)
            {
                principal.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);

                texturaVideo = videoPlayer.GetTexture();

                principal.SpriteBatch.Draw(texturaVideo, retangulo, Color.White);

                principal.SpriteBatch.End();
            }

            base.Draw(gameTime);
        }
        /// <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(SpriteBatch spriteBatch)
        {
            videotexture = videoplayer.GetTexture();
            // TODO: Add your drawing code here



            spriteBatch.Draw(background, new Rectangle(0, 0, 800, 600), Color.White);
            spriteBatch.Draw(videotexture, videotexturerect, Color.White);


            if (videoplayer.State == MediaState.Stopped)
            {
                spriteBatch.DrawString(font, "PRESS ENTER", new Vector2(0, 0), Color.White);
            }
        }
Exemple #27
0
        public override void Draw(SpriteBatch batch)
        {
            base.Draw(batch);

            if (videoPlayer != null && videoPlayer.State == MediaState.Playing)
            {
                batch.Draw(videoPlayer.GetTexture(), videoRect, Color.White);
            }
            else if (started)
            {
                hasPlayedOnce = true;
                started       = false;
                completed     = true;
                //((Screen)parent).nextState = MenuState.MainMenu;
            }
        }
        /// <summary>
        /// This is called when the screen should draw itself.
        /// </summary>
        /// <param name="gameTime"></param>
        /// <param name="render"></param>
        protected override void  Draw(GameTime gameTime, RenderHelper render)
        {
            render.Clear(backGoundColor);
            Texture2D videoTexture = null;

            if (videoPlayer.State != MediaState.Stopped)
            {
                videoTexture = videoPlayer.GetTexture();
            }

            // Draw the video, if we have a texture to draw.
            if (videoTexture != null)
            {
                render.RenderTextureComplete(videoTexture, Color.White, GraphicInfo.FullScreenRectangle, Matrix.Identity);
            }
        }
Exemple #29
0
        private void DrawVideoFrame()
        {
            spriteBatch.Begin();

            if (videoPlayer.State != MediaState.Stopped)
            {
                Texture2D videoTexture = videoPlayer.GetTexture();
                Rectangle videoRectangle = GetScreenDimensionsForVideo();
                if (videoTexture != null)
                {
                    spriteBatch.Draw(videoTexture, videoRectangle, Color.White);
                }
            }
            
            spriteBatch.End();
        }
        public override void Draw(SpriteBatch spriteBatch)
        {
            Texture2D videoTexture = null;

            if (player.State != MediaState.Stopped)
            {
                videoTexture = player.GetTexture();
            }

            if (videoTexture != null)
            {
                spriteBatch.Draw(videoTexture, splashrect, splashColor);
            }

            base.Draw(spriteBatch);
        }