예제 #1
0
        /// <summary>
        /// draws the room and everything inside it
        /// </summary>
        /// <param name="spriteBatch">the sprite batch to draw to</param>
        public void Draw(SpriteBatch spriteBatch)
        {
            Vector2 ceiledOffset = new Vector2((float)(Math.Ceiling(Math.Abs(ViewPosition.X) * Math.Sign(ViewPosition.X))), (float)(Math.Ceiling(Math.Abs(ViewPosition.Y) * Math.Sign(ViewPosition.Y))));

            spriteBatch.GraphicsDevice.SetRenderTarget(LightTarget);
            spriteBatch.GraphicsDevice.Clear(Color.Black);
            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive);
            for (int i = 0; i < LightList.Count; i++)
            {
                Light light = LightList[i];
                light.Draw(spriteBatch, ceiledOffset);
            }
            spriteBatch.End();
            spriteBatch.GraphicsDevice.SetRenderTarget(MainTarget);
            spriteBatch.GraphicsDevice.Clear(Color.LightGray);
            spriteBatch.Begin(SpriteSortMode.FrontToBack);
            if (currentTransition != null && currentTransition.IsActive)
            {
                currentTransition.Draw(spriteBatch);
            }
            Background.Draw(spriteBatch, new Vector2(0, 0));
            for (int i = 0; i < GameObjectList.Count; i++)
            {
                GameObjectList[i].Draw(spriteBatch, ceiledOffset);
            }
            for (int i = 0; i < GameTileList.Count; i++)
            {
                GameTileList[i].Draw(spriteBatch, ceiledOffset);
            }
            spriteBatch.End();
            spriteBatch.GraphicsDevice.SetRenderTarget(null);
            spriteBatch.GraphicsDevice.Clear(Color.Black);
            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
            if (LightEffect != null)
            {
                LightEffect.Parameters["lightMask"].SetValue(LightTarget);
                LightEffect.CurrentTechnique.Passes[0].Apply();
            }
            spriteBatch.Draw(MainTarget, new Vector2(0, 0), Color.White);
            spriteBatch.End();
        }
예제 #2
0
 /// <summary>
 /// draws the tile
 /// </summary>
 /// <param name="spriteBatch">the sprite batch to draw to</param>
 /// <param name="viewPosition">the view offset correpsonding to the view position</param>
 public virtual void Draw(SpriteBatch spriteBatch, Vector2 viewPosition)
 {
     Sprite?.Draw(spriteBatch, Position - viewPosition);
 }
예제 #3
0
 public void Draw(SpriteBatch spriteBatch, Vector2 viewPosition)
 {
     Sprite.Draw(spriteBatch, Position - viewPosition, Color);
 }
예제 #4
0
 public void Draw(SpriteBatch spriteBatch, Vector2 offset)
 {
     Image?.Draw(spriteBatch, offset);
 }