Пример #1
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(Color.Black);
            mRefreshTimer += (float)_gameTime.ElapsedGameTime.TotalMilliseconds;

            // Check if a 2D camera exists, configure spritebatch accordingly
            if (mCamera != null)
            {
                mSpriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend,
                                   null, null, null, null, mCamera.GetTransform(GraphicsDevice));
            }
            else
            {
                mSpriteBatch.Begin();
            }

            mBackgroundManager.Draw(mSpriteBatch, _gameTime);

            if (mRefreshTimer >= mRefreshRate)
            {
                mSceneManager.Draw(mSpriteBatch, _gameTime);
                if (Global.GameState == Global.availGameStates.Menu)
                {
                    mMenuManager.Draw(mSpriteBatch);
                }
                // TODO: Add your drawing code here
                mRefreshTimer = 0f;
            }
            mSpriteBatch.End();
            base.Draw(_gameTime);
        }
Пример #2
0
        // For use if camera is to follow player
        public void Draw(SpriteBatch spriteBatch, Camera2D cam, GraphicsDevice graDev)
        {
            spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend,
                              null, null, null, null, cam.GetTransform(graDev));
            RoomManager.getInstance.Draw(spriteBatch);

            // Only run draw if not in Game Over state
            if (Global.GameState != Global.availGameStates.GameOver)
            {
                // Update Texture path for animating entity
                mEntities.ForEach(IEntity => IEntity.aTexture = Content.Load <Texture2D>(IEntity.aTexturename));
                // Call draw method for each Entity if entity is visible
                for (int i = 0; i < mEntities.Count; i++)
                {
                    if (mEntities[i].Visible)
                    {
                        mEntities[i].Draw(spriteBatch);
                    }
                }
                // Run Dialogue display if game in Dialogue State
                if (Global.GameState == Global.availGameStates.Dialogue)
                {
                    DialogueBox.getInstance.Draw(spriteBatch);
                }
                if (Global.GameState == Global.availGameStates.Paused &&
                    MenuManager.getInstance.PauseMenu() != null)
                {
                    MenuManager.getInstance.PauseMenu().Draw(spriteBatch);
                }
            }
            else if (MenuManager.getInstance.GameOverMenu() != null &&
                     Global.GameState == Global.availGameStates.GameOver)
            {
                MenuManager.getInstance.GameOverMenu().Draw(spriteBatch);
            }

            spriteBatch.End();
        }