Esempio n. 1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            GraphicsDevice.SetRenderTarget(_renderTarget);
            _screens.Draw(_renderer);
            GraphicsDevice.SetRenderTarget(null);

            Vector2 scale;
            float   windowRatio = GraphicsDevice.Viewport.AspectRatio;
            float   renderRatio = (float)GameProperties.Width / GameProperties.Height;

            if (renderRatio > windowRatio)
            {
                scale = new Vector2((float)GraphicsDevice.Viewport.Width / GameProperties.Width);
            }
            else
            {
                scale = new Vector2((float)GraphicsDevice.Viewport.Height / GameProperties.Height);
            }

            _spriteBatch.Begin(samplerState: SamplerState.PointClamp);
#pragma warning disable CS0618 // Type or member is obsolete
            _spriteBatch.Draw(_renderTarget,
                              position: GraphicsDevice.Viewport.Bounds.Center.ToVector2(),
                              origin: _renderTarget.Bounds.Center.ToVector2(),
                              scale: scale);
#pragma warning restore CS0618 // Type or member is obsolete
            _spriteBatch.End();

            base.Draw(gameTime);
        }
Esempio n. 2
0
        public void DrawUnderNotActiveGameScreen()
        {
            var screens = new ScreenStack();

            var screen = new Mock <IScreen>();

            screen.Setup(x => x.IsActive).Returns(true);

            var gamescreen = new Mock <IGameScreen>();

            gamescreen.Setup(x => x.TransitionState).Returns(TransitionState.TransitionOn);
            gamescreen.Setup(x => x.CoverOtherScreens).Returns(false);
            gamescreen.Setup(x => x.IsActive).Returns(true);

            screens.Screens.Add(screen.Object);
            screens.Screens.Add(gamescreen.Object);

            var time = new GameTime();

            screens.Draw(new GameTime());

            gamescreen.Verify(x => x.Draw(It.IsAny <GameTime>()), Times.Once);
            screen.Verify(x => x.Draw(It.IsAny <GameTime>()), Times.Once);
        }