public override void OnDraw(float elapsedTime)
        {
            _gameBackground.Draw();
            _weather.Draw(elapsedTime);
            Game.DepthRenderer.Draw(Game.SpriteBatch);

            _explosionManager.Draw();

            Game.ShapeRenderer.DrawFilledRectangle(0, 0, 800, 600, Color.White * _weather._sun._blendVal);
            _weather._cloud.RenderRainOnTop(elapsedTime);

            //Game.ShapeRenderer.DrawFilledRectangle(0, 0, 800, 600, Color.Gray * 0.5f);
        }
示例#2
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)
        {
            //GraphicsDevice.Clear(new Color(20, 20, 40));
            GraphicsDevice.Clear(Color.Black);

            // TODO: Add your drawing code here
            // Draw the sprite.
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
            myGameBackground.Draw(spriteBatch, gameTime);

            if (!OnMenu)
            {
                myPlayer.Draw(spriteBatch, gameTime);
                myLevel.Draw(spriteBatch, gameTime);
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }
示例#3
0
        private void DrawGameplay(SpriteBatch spriteBatch, GameTime gameTime)
        {
            GameBackground.Draw(gameTime, spriteBatch);

            this._elements.Draw(spriteBatch);

            this.GameCharacter.Draw(spriteBatch);

            DrawOnetimeAnimations(spriteBatch);

            float position = 15;

            spriteBatch.DrawString(_font[2], "Level: " + this._currentLevel.ToString(), new Vector2(position, 20), GhostlyGame.MENU_FONT_COLOR);

            position = _font[2].MeasureString("Level: " + this._currentLevel.ToString()).X + 100;

            switch (this.GameCharacter.CurrentHealth)
            {
            case 3:
                spriteBatch.Draw(ImagesAndAnimations.Instance.HeartFull, new Rectangle((int)position, 20, 53, 45), Color.White);
                break;

            case 2:
                spriteBatch.Draw(ImagesAndAnimations.Instance.HeartHalf, new Rectangle((int)position, 20, 53, 45), Color.White);
                break;

            case 1:
                spriteBatch.Draw(ImagesAndAnimations.Instance.HeartEmpty, new Rectangle((int)position, 20, 53, 45), Color.White);
                break;

            default:
                spriteBatch.Draw(ImagesAndAnimations.Instance.InvisibleTile, new Rectangle((int)position, 20, 53, 45), Color.White);
                break;
            }

            position += 153;

            spriteBatch.DrawString(_font[2], "Score: " + GameCharacter.Score.ToString(), new Vector2(position, 20), GhostlyGame.MENU_FONT_COLOR);
        }
示例#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
        }