コード例 #1
0
        public override void Draw(GameTime gameTime)
        {
            YnG3.RestoreGraphicsDeviceStates();

            base.Draw(gameTime);

            spriteBatch.Begin();

            _gameHUD.Draw(gameTime, spriteBatch);

            if (virtualPad.Visible)
            {
                virtualPad.Draw(gameTime, spriteBatch);
            }

            spriteBatch.End();
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: satwinders97/MyProjects
        /// <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)
        {
            if (Level.IsOutside)
            {
                GraphicsDevice.Clear(Color.CornflowerBlue);
            }
            else
            {
                GraphicsDevice.Clear(new Color(new Vector3(150 / 255.0f, 175 / 255.0f, 175 / 255.0f)));
            }

            spriteBatch.Begin(blendState: BlendState.AlphaBlend);

            LevelScroller.Draw(spriteBatch);

            GameHUD.Draw(spriteBatch);

            spriteBatch.End();

            base.Draw(gameTime);
        }
コード例 #3
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            //Take care of any viewport adjustments for our final draw:
            Resolution.BeginDraw();

            //Pass the camera matrix into SpriteBatch.Begin(), it will move all of our images based on the camera's location etc:
            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Camera.GetTransformMatrix());
#if DEBUG
            editor.Draw(spriteBatch);
#endif
            DrawObjects();
            map.DrawWalls(spriteBatch);
            spriteBatch.End();

            //After drawing the things effected by the camera, we can draw the GameHUD on top of it:
            gameHUD.Draw(spriteBatch);

            base.Draw(gameTime);
        }
コード例 #4
0
        private void InternalDraw(SAMTime gameTime, Rectangle?scissor)
        {
#if DEBUG
            FPSCounter.StartCycle(gameTime);
#endif
            VAdapterGame.Update();
            VAdapterHUD.Update();

            if (_clearScreenOnDraw)
            {
                Graphics.GraphicsDevice.Clear(Color.Magenta);
            }

            // Update Top Down  (Debug -> HUD -> Entities -> BG)
            // Render Bottom Up (BG -> Entities -> GPU_Particle -> HUD -> Debug)

            var bts = GetBaseTextureScale();
            var mat = Matrix.CreateTranslation(MapOffsetX, MapOffsetY, 0) * VAdapterGame.GetScaleMatrix();

            // ======== GAME =========

#if DEBUG
            if (_updateDebugSettings)
            {
                TIMING_DRAW_BATCH_GAME.Start();
            }
#endif

            TranslatedBatch.OnBegin(bts);
            if (scissor == null)
            {
                InternalBatch.Begin(transformMatrix: mat);
            }
            else
            {
                GraphicsDevice.ScissorRectangle = scissor.Value;
                InternalBatch.Begin(transformMatrix: mat, rasterizerState: new RasterizerState {
                    ScissorTestEnable = true
                });
            }
            try
            {
#if DEBUG
                if (_updateDebugSettings)
                {
                    TIMING_DRAW_BACKGROUND.Start();
                }
#endif
                Background.Draw(TranslatedBatch);
#if DEBUG
                if (_updateDebugSettings)
                {
                    TIMING_DRAW_BACKGROUND.Stop();
                }
#endif

#if DEBUG
                if (_updateDebugSettings)
                {
                    TIMING_DRAW_ENTITIES.Start();
                }
#endif
                Entities.Draw(TranslatedBatch);
#if DEBUG
                if (_updateDebugSettings)
                {
                    TIMING_DRAW_ENTITIES.Stop();
                }
#endif

#if DEBUG
                if (_updateDebugSettings)
                {
                    TIMING_DRAW_SCREEN.Start();
                }
#endif
                OnDrawGame(TranslatedBatch);
#if DEBUG
                if (_updateDebugSettings)
                {
                    TIMING_DRAW_SCREEN.Stop();
                }
#endif

#if DEBUG
                if (_updateDebugSettings)
                {
                    TIMING_DRAW_BACKGROUNDPOST.Start();
                }
#endif
                Background.DrawOverlay(TranslatedBatch);
#if DEBUG
                if (_updateDebugSettings)
                {
                    TIMING_DRAW_BACKGROUNDPOST.Stop();
                }
#endif

#if DEBUG
                DrawScreenDebug(TranslatedBatch);
#endif
            }
            finally
            {
                InternalBatch.End();
                TranslatedBatch.OnEnd();
            }

#if DEBUG
            if (_updateDebugSettings)
            {
                TIMING_DRAW_BATCH_GAME.Stop();
            }
#endif

            // ======== STUFF ========

#if DEBUG
            if (_updateDebugSettings)
            {
                TIMING_DRAW_ENTITIESPOST.Start();
            }
#endif
            Entities.PostDraw();
#if DEBUG
            if (_updateDebugSettings)
            {
                TIMING_DRAW_ENTITIESPOST.Stop();
            }
#endif

            // ======== HUD ==========

#if DEBUG
            if (_updateDebugSettings)
            {
                TIMING_DRAW_BATCH_HUD.Start();
            }
#endif

            FixedBatch.OnBegin(bts);

            if (scissor == null)
            {
                InternalBatch.Begin(transformMatrix: VAdapterHUD.GetScaleMatrix());
            }
            else
            {
                GraphicsDevice.ScissorRectangle = scissor.Value;
                InternalBatch.Begin(transformMatrix: VAdapterHUD.GetScaleMatrix(), rasterizerState: new RasterizerState {
                    ScissorTestEnable = true
                });
            }
            try
            {
#if DEBUG
                if (_updateDebugSettings)
                {
                    TIMING_DRAW_HUD.Start();
                }
#endif
                GameHUD.Draw(FixedBatch);
#if DEBUG
                using (FixedBatch.BeginDebugDraw()) DebugMap.Draw(FixedBatch);
                if (_updateDebugSettings)
                {
                    TIMING_DRAW_HUD.Stop();
                }
#endif
                OnDrawHUD(TranslatedBatch);
            }
            finally
            {
                InternalBatch.End();
                FixedBatch.OnEnd();
            }

#if DEBUG
            if (_updateDebugSettings)
            {
                TIMING_DRAW_BATCH_HUD.Stop();
            }
#endif

            // =======================

#if DEBUG
            if (_updateDebugSettings)
            {
                TIMING_DRAW_DEBUGSCREEN.Start();
            }
            using (FixedBatch.BeginDebugDraw())
                using (TranslatedBatch.BeginDebugDraw())
                {
                    Entities.DrawOuterDebug();
                    DebugDisp.Draw();
                }
            if (_updateDebugSettings)
            {
                TIMING_DRAW_DEBUGSCREEN.Stop();
            }
#endif

#if DEBUG
            if (_updateDebugSettings)
            {
                TIMING_DRAW_PROXIES.Start();
            }
#endif
            foreach (var proxy in _proxyScreens)
            {
                if (proxy.ProxyTargetBounds.IsEmpty)
                {
                    continue;
                }
                proxy.Proxy._clearScreenOnDraw   = false;
                proxy.Proxy._updateDebugSettings = false;

                proxy.Proxy.InternalDraw(gameTime, proxy.ProxyTargetBounds.CeilOutwards());
            }
#if DEBUG
            if (_updateDebugSettings)
            {
                TIMING_DRAW_PROXIES.Stop();
            }
#endif

#if DEBUG
            FPSCounter.EndCycle();
#endif
        }