Example #1
0
        public override void Render(Batcher batcher, Camera camera)
        {
            foreach (var val in farm.InvalidTiles)
            {
                batcher.DrawHollowRect(new Vector2(val.X, val.Y) * Tile.SpriteSize, Tile.SpriteSize, Tile.SpriteSize, Color.Red, this.hollowRectBorderThickness);
            }

            if (this.HighlightTileAtMouse)
            {
                var p = this.playerCamera.MouseToTilePosition();
                batcher.DrawHollowRect(p * Tile.SpriteSize, Tile.SpriteSize, Tile.SpriteSize, Color.Green, this.hollowRectBorderThickness);
            }
        }
        public void DrawOutline(Batcher batcher, Point gridLocation, Color color, int thickness = 1)
        {
            Point offset      = new Point(Constants.pixelsPerTile * gridLocation.X, -Constants.pixelsPerTile * gridLocation.Y);
            Point totalOffset = offset + Transform.Position.ToPoint();

            batcher.DrawHollowRect(new Rectangle(totalOffset.X, totalOffset.Y, Constants.pixelsPerTile, Constants.pixelsPerTile), color, thickness);
        }
Example #3
0
 /// <summary>
 /// Draws this element's debug lines
 /// </summary>
 /// <param name="batcher">Batcher.</param>
 public virtual void DebugRender(Batcher batcher)
 {
     if (_debug)
     {
         batcher.DrawHollowRect(x, y, width, height, Color.Red);
     }
 }
Example #4
0
        public override void Render(Batcher batcher, Camera camera)
        {
            var cellSize = new Point(map.TileWidth, map.TileHeight);
            // FIXME: how to get tiled offset
            var tiledOffset = Core.Scene.FindEntity(EntityNames.tiled).Position.ToPoint();

            // settings
            var rect      = new SpriteData(Graphics.Instance.PixelTexture, cellSize, cellSize);
            var grid      = new SpriteData(Graphics.Instance.PixelTexture, cellSize - new Point(4, 4), cellSize);
            var gridColor = Color.WhiteSmoke * 0.25f;

            // copied from TiledRendering class
            var bounds = camera.Bounds;
            var scale  = new Vector2(1, 1);
            var minX   = this.map.WorldToTilePositionX(bounds.Left - (this.map.MaxTileWidth * scale.X - map.TileWidth));
            var minY   = this.map.WorldToTilePositionY(bounds.Top - (this.map.MaxTileHeight * scale.Y - map.TileHeight));
            var maxX   = this.map.WorldToTilePositionX(bounds.Right + (this.map.MaxTileWidth * scale.X - map.TileWidth));
            var maxY   = this.map.WorldToTilePositionY(bounds.Bottom + (this.map.MaxTileHeight * scale.Y - map.TileHeight));

            for (var y = minY; y <= maxY; y++)
            {
                for (var x = minX; x <= maxX; x++)
                {
                    var pos = new Point(x * cellSize.X, y * cellSize.Y);

                    if (this.fow.isCovered(x, y))
                    {
                        // hide the cell
                        // var color = Color.Black * 0.9f;
                        var color    = Color.Black;
                        var destRect = new Rectangle(pos.X + rect.offset.X, pos.Y + rect.offset.Y, rect.size.X, rect.size.Y);
                        destRect.Offset(tiledOffset); // FIXME
                        batcher.Draw(rect.sprite, destRect, rect.sprite.SourceRect, color,
                                     this.Entity.Transform.Rotation, SpriteEffects.None, this.LayerDepth,
                                     0f, 0f, 0f, 0f
                                     );
                        continue;
                    }

                    // draw grid to visible & walkable cells
                    if (this.fov.canSee(x, y) && !this.stage.isBlocked(x, y))
                    {
                        var destRect = new Rectangle(pos.X + grid.offset.X, pos.Y + grid.offset.Y, grid.size.X, grid.size.Y);
                        destRect.Offset(tiledOffset); // FIXME
                        batcher.DrawHollowRect(destRect, gridColor);
                    }

                    { // draw shadow
                        var color    = Color.Black * this.getAlphaAt(x, y);
                        var destRect = new Rectangle(pos.X + rect.offset.X, pos.Y + rect.offset.Y, rect.size.X, rect.size.Y);
                        destRect.Offset(tiledOffset); // FIXME
                        batcher.Draw(rect.sprite, destRect, rect.sprite.SourceRect, color,
                                     this.Entity.Transform.Rotation, SpriteEffects.None, this.LayerDepth,
                                     0f, 0f, 0f, 0f
                                     );
                    }
                }
            }
        }
Example #5
0
            private void DrawMouseOverlay(Batcher batcher, Camera camera)
            {
                Vector2 mousePos = camera.ScreenToWorldPoint(Input.CurrentMouseState.Position.ToVector2());

                if (GameBoard.InBounds(mousePos))
                {
                    Point boardMousePos = GameBoard.WorldToBoard(camera.ScreenToWorldPoint(Input.MousePosition));
                    batcher.DrawHollowRect(GetCellRectangle(boardMousePos), Color.Red, 10f);
                }
            }
Example #6
0
        public override void DebugRender(Batcher batcher)
        {
            base.DebugRender(batcher);

            foreach (Connection c in connections.Values)
            {
                batcher.DrawLine(Position, Position + Direction8Ext.ToVector2(c.direction) * 50, Color.Chartreuse, 5);
            }

            if (roadSystem.truckTargetNode == this)
            {
                batcher.DrawHollowRect(new Rectangle((int)Position.X - 25, (int)Position.Y - 25, 50, 50), Color.White, 5);
            }
        }
        public override void Render(Batcher batcher, Camera camera)
        {
            batcher.DrawHollowRect(Transform.Position, Width, Height, OutlineColour, 6);
            batcher.DrawRect(Transform.Position, Width, Height, BackgroundColour);
            Point offset = new Point(0, -2);

            foreach (var pieceDef in queue)
            {
                offset.Y += pieceDef.height + 1;
                foreach (Point point in pieceDef.shape)
                {
                    Utilities.DrawTile(batcher, point - offset, new Point(padding + Constants.pixelsPerTile, padding + Constants.pixelsPerTile) + Transform.Position.ToPoint(), pieceDef.type);
                }
            }
            batcher.DrawCircle(Transform.Position, 3, Color.Red);
        }
        public override void Render(Batcher batcher, Camera camera)
        {
            batcher.DrawHollowRect(Transform.Position, Width, Height, OutlineColour, 6);
            batcher.DrawRect(Transform.Position, Width, Height, BackgroundColour);
            Point offset = new Point(0, 1);

            if (heldPiece != null)
            {
                foreach (Point point in heldPiece.shape)
                {
                    Utilities.DrawTile(batcher, point - offset, new Point(padding + Constants.pixelsPerTile, padding + Constants.pixelsPerTile) + Transform.Position.ToPoint(), heldPiece.type);
                }
            }

            batcher.DrawCircle(Transform.Position, 3, Color.Red);
        }
        public override void Render(Batcher batcher, Camera camera)
        {
            batcher.DrawCircle(Transform.Position, 2, Color.Red);
            batcher.DrawHollowRect((Transform.Position.RoundToPoint() - new Point(0, height * Constants.pixelsPerTile)).ToVector2(), Width, Height, OutlineColour, 6);
            batcher.DrawRect((Transform.Position.RoundToPoint() - new Point(0, height * Constants.pixelsPerTile)).ToVector2(),
                             Width, Height, BackgroundColour);

            for (int y = 0; y < height + 2; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    DrawGridTile(batcher, new Point(x, y));
                }
            }

            foreach (var player in players)
            {
                var piece = player.piece;
                if (piece != null)
                {
                    var ghost = piece.GetLandedOffset();
                    foreach (Point point in piece.Shape)
                    {
                        DrawOutline(batcher, point + piece.position, player.outlineTint, 6);
                        DrawOutline(batcher, point + piece.position + ghost, player.outlineTint, 6);
                    }
                    foreach (Point point in piece.Shape)
                    {
                        Utilities.DrawTile(batcher, point + piece.position + ghost, Transform.Position.ToPoint(), piece.definition.type, piece.definition.type.ghostColor);
                    }
                    foreach (Point point in piece.Shape)
                    {
                        Utilities.DrawTile(batcher, point + piece.position, Transform.Position.ToPoint(), piece.definition.type);
                    }
                    int temp = 0;
                    foreach (Point point in piece.outline)
                    {
                        Point gridOffset = point + piece.position;
                        Point offset     = new Point(Constants.pixelsPerTile * gridOffset.X, -Constants.pixelsPerTile * gridOffset.Y);
                        batcher.DrawCircle(Transform.Position + offset.ToVector2(), 2, Color.Green);
                        batcher.DrawString(Graphics.Instance.BitmapFont, temp + "", Transform.Position + offset.ToVector2(), Color.White);
                        temp++;
                    }
                }
            }
        }
Example #10
0
        public virtual void Draw(Batcher batcher, float x, float y, float width, float height, Color color)
        {
            var col = Color ?? color;

            if (color.A != 255)
            {
                col *= (color.A / 255f);
            }
            if (col.A != 255)
            {
                col *= (col.A / 255f);
            }

            if (UseFilledRect)
            {
                batcher.DrawRect(x, y, width, height, col);
            }
            else
            {
                batcher.DrawHollowRect(x, y, width, height, col);
            }
        }
Example #11
0
        public override void DebugRender(Batcher batcher)
        {
            base.DebugRender(batcher);
            var mapRepr = playState.map;

            if (mapRepr == null)
            {
                return;
            }
            // draw points for each point on the map graph
            foreach (var node in mapRepr.sng.nodes)
            {
                Vector2 toWorldPos(Point tilePos) => mapRenderer.TiledMap.TileToWorldPosition(tilePos.ToVector2());

                batcher.DrawHollowRect(toWorldPos(node.pos), 4f, 4f, Color.GreenYellow, 1f);
                // draw edges
                foreach (var adj in node.links)
                {
                    batcher.DrawLine(toWorldPos(node.pos), toWorldPos(adj.pos), Color.GreenYellow, 1f);
                }
            }
        }
Example #12
0
 void drawIndicator(Batcher batcher, Vector2 pos, Color col, float size = 4f, float thickness = 1f)
 {
     batcher.DrawHollowRect(
         new RectangleF(pos.X - size, pos.Y - size, size * 2, size * 2),
         col, thickness);
 }