Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Main.cs, main draw call:
- protected override void Draw(GameTime gameTime)
- {
- #region Draw World
- //begin and end calls are taken care of inside world.Draw
- world?.Draw(batch);
- world?.DrawExtraEntity(batch, "outline");
- CompoundShaderDraw.Draw(batch, entityTarget, effectCompoundTarget, Color.Transparent, BlendState.AlphaBlend, outlineEffects);
- GraphicsDevice.SetRenderTarget(worldTarget);
- GraphicsDevice.Clear(Color.Black);
- batch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, null, null, null);
- batch.Draw(bgTilesTarget, Vector2.Zero, null, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0);
- batch.Draw(entityTarget, Vector2.Zero, null, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0);
- batch.Draw(fgTilesTarget, Vector2.Zero, null, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0);
- batch.End();
- #endregion
- world?.DrawExtraEntity(batch, "cutout");
- #region Draw UI
- GraphicsDevice.SetRenderTarget(uiTarget);
- GraphicsDevice.Clear(Color.Transparent);
- batch.Begin(SpriteSortMode.FrontToBack, BlendState.NonPremultiplied, SamplerState.PointWrap, DepthStencilState.DepthRead, null, null, null);
- batch.DrawRectangle(new RectangleF(0, 0, width, height * (screenCoverPercent / 2f)), Color.Black);
- batch.DrawRectangle(new RectangleF(0, height - (height * (screenCoverPercent / 2f)), width, height * (screenCoverPercent / 2f)), Color.Black);
- menuManager.Draw(batch);
- dialogueManager.Draw(batch);
- batch.End();
- #endregion
- #region Draw Final
- GraphicsDevice.SetRenderTarget(finalTarget);
- GraphicsDevice.Clear(Color.Black);
- batch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, null, null, null);
- batch.Draw(worldTarget, Vector2.Zero, null, Color.White, 0, Vector2.Zero, new Vector2(ScaleX, ScaleY), SpriteEffects.None, 0);
- batch.End();
- BlendState bs = new BlendState()
- {
- AlphaDestinationBlend = Blend.One,
- ColorDestinationBlend = Blend.InverseSourceColor,
- ColorBlendFunction = BlendFunction.Add,
- AlphaSourceBlend = Blend.Zero,
- ColorSourceBlend = Blend.Zero,
- };
- batch.Begin(SpriteSortMode.FrontToBack, bs, SamplerState.PointClamp, DepthStencilState.None, null, null, null);
- batch.Draw(cutoutTarget, Vector2.Zero, null, Color.White, 0, Vector2.Zero, Scale, SpriteEffects.None, 0);
- batch.End();
- batch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, null, null, null);
- batch.Draw(uiTarget, Vector2.Zero, null, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0);/**/
- batch.End();
- #endregion
- #region Draw Final To Backbuffer
- GraphicsDevice.SetRenderTarget(null);
- GraphicsDevice.Clear(Color.Black);
- batch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.PointWrap, DepthStencilState.DepthRead, null, null, null);
- batch.Draw(finalTarget, Vector2.Zero, null, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0);
- batch.End();
- #endregion
- base.Draw(gameTime);
- }
- World.cs:
- public virtual void DrawExtraEntity(SpriteBatch batch, string mode)
- {
- if (mode == "outline")
- {
- batch.GraphicsDevice.SetRenderTarget(Main.Instance.outlineTarget);
- batch.GraphicsDevice.Clear(Color.Transparent);
- batch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, null, null, null);
- for (int i = 0; i < maxEntities; i++)
- {
- Entity e = entities[i];
- e.DrawExtra(batch, mode);
- }
- batch.End();
- }
- else if (mode == "cutout")
- {
- batch.GraphicsDevice.SetRenderTarget(Main.Instance.cutoutTarget);
- batch.GraphicsDevice.Clear(Color.Orange);
- batch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, null, null, null);
- for (int i = 0; i < maxEntities; i++)
- {
- Entity e = entities[i];
- e.DrawExtra(batch, mode);
- }
- batch.End();
- }
- }
- Player.cs:
- public override void DrawExtra(SpriteBatch batch, string mode)
- {
- base.DrawExtra(batch, mode);
- if (mode == "cutout")
- batch.Draw(Main.assetsManager.GetAsset<Texture2D>("circle"), Entity.position - Main.cameraPos, null, Color.Black, 0, new Vector2(512), 0.25f, SpriteEffects.None, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement