public void Render(RendererParameters parameters) { parameters.ThrowIfNull("parameters"); if (!_state.Enabled || _state.TopLeftSelectionCoordinate == null) { return; } const int tileWidth = TextAdventure.Xna.Constants.Tile.TileWidth; const int tileHeight = TextAdventure.Xna.Constants.Tile.TileHeight; var topLeftPoint = new Point( _editorView.TopLeftPoint.X + (_state.TopLeftSelectionCoordinate.Value.X * tileWidth), _editorView.TopLeftPoint.Y + (_state.TopLeftSelectionCoordinate.Value.Y * tileHeight)); var destinationRectangle = new Rectangle(topLeftPoint.X, topLeftPoint.Y, tileWidth * _state.SelectionSize, tileHeight * _state.SelectionSize); var topLine = new Rectangle(destinationRectangle.X, destinationRectangle.Y, destinationRectangle.Width, 1); var bottomLine = new Rectangle(destinationRectangle.X, destinationRectangle.Bottom - 1, destinationRectangle.Width, 1); var leftLine = new Rectangle(destinationRectangle.X, destinationRectangle.Y, 1, destinationRectangle.Height); var rightLine = new Rectangle(destinationRectangle.Right - 1, destinationRectangle.Y, 1, destinationRectangle.Height); Texture2D pixelTexture = parameters.TextureContent.Pixel; parameters.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, new ScissoringRasterizerState()); parameters.SpriteBatch.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, _editorView.VisibleBoardSizeInPixels.Width, _editorView.VisibleBoardSizeInPixels.Height); parameters.SpriteBatch.Draw(pixelTexture, topLine, Color.Red); parameters.SpriteBatch.Draw(pixelTexture, bottomLine, Color.Red); parameters.SpriteBatch.Draw(pixelTexture, leftLine, Color.Red); parameters.SpriteBatch.Draw(pixelTexture, rightLine, Color.Red); parameters.SpriteBatch.End(); }
public void Render(RendererParameters parameters) { parameters.ThrowIfNull("parameters"); parameters.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, RasterizerState.CullNone); var rectangle = new Rectangle(0, 0, _editorView.VisibleBoardSizeInPixels.Width, _editorView.VisibleBoardSizeInPixels.Height); Texture2D texture = parameters.TextureContent.Hatch; rectangle.Width = MathHelper.Instance.QuantizationCeiling(rectangle.Width, 8); rectangle.Height = MathHelper.Instance.QuantizationCeiling(rectangle.Height, 8); parameters.SpriteBatch.Draw(texture, rectangle, rectangle, Constants.HatchRenderer.Color); parameters.SpriteBatch.End(); }
public void Render(RendererParameters parameters) { parameters.ThrowIfNull("parameters"); Board board = _state.Board; if (board == null) { return; } IEnumerable<ILayer> layers = new ILayer[] { _state.Board.BackgroundLayer, _state.Board.ForegroundLayer, _state.Board.ActorInstanceLayer }; Coordinate topLeftCoordinate = _editorView.TopLeftCoordinate; var bottomRightCoordinate = new Coordinate(topLeftCoordinate.X + _editorView.ClientSizeInTiles.Width - 1, topLeftCoordinate.Y + _editorView.ClientSizeInTiles.Height - 1); parameters.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone); foreach (ILayer layer in layers) { IEnumerable<Tile> tiles = layer.Tiles.Where( arg => arg.Coordinate.X >= topLeftCoordinate.X && arg.Coordinate.X <= bottomRightCoordinate.X && arg.Coordinate.Y >= topLeftCoordinate.Y && arg.Coordinate.Y <= bottomRightCoordinate.Y); foreach (Tile tile in tiles) { Rectangle destinationRectangle = GetTileDestinationRectangle(_editorView.TopLeftPoint, topLeftCoordinate, tile.Coordinate); parameters.SpriteBatch.Draw(parameters.TextureContent.Pixel, destinationRectangle, parameters.TextureContent.Pixel.Bounds, tile.Character.BackgroundColor.ToXnaColor()); Rectangle symbolSourceRectangle = CharacterTextureHelper.GetSymbolSourceRectangle(tile.Character.Symbol); parameters.SpriteBatch.Draw(parameters.TextureContent.Characters, destinationRectangle, symbolSourceRectangle, tile.Character.ForegroundColor.ToXnaColor()); } } parameters.SpriteBatch.End(); }
public void Render(RendererParameters parameters) { parameters.ThrowIfNull("parameters"); Board board = _state.Board; if (board == null) { return; } IEnumerable <ILayer> layers = new ILayer[] { _state.Board.BackgroundLayer, _state.Board.ForegroundLayer, _state.Board.ActorInstanceLayer }; Coordinate topLeftCoordinate = _editorView.TopLeftCoordinate; var bottomRightCoordinate = new Coordinate(topLeftCoordinate.X + _editorView.ClientSizeInTiles.Width - 1, topLeftCoordinate.Y + _editorView.ClientSizeInTiles.Height - 1); parameters.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone); foreach (ILayer layer in layers) { IEnumerable <Tile> tiles = layer.Tiles.Where( arg => arg.Coordinate.X >= topLeftCoordinate.X && arg.Coordinate.X <= bottomRightCoordinate.X && arg.Coordinate.Y >= topLeftCoordinate.Y && arg.Coordinate.Y <= bottomRightCoordinate.Y); foreach (Tile tile in tiles) { Rectangle destinationRectangle = GetTileDestinationRectangle(_editorView.TopLeftPoint, topLeftCoordinate, tile.Coordinate); parameters.SpriteBatch.Draw(parameters.TextureContent.Pixel, destinationRectangle, parameters.TextureContent.Pixel.Bounds, tile.Character.BackgroundColor.ToXnaColor()); Rectangle symbolSourceRectangle = CharacterTextureHelper.GetSymbolSourceRectangle(tile.Character.Symbol); parameters.SpriteBatch.Draw(parameters.TextureContent.Characters, destinationRectangle, symbolSourceRectangle, tile.Character.ForegroundColor.ToXnaColor()); } } parameters.SpriteBatch.End(); }