Example #1
0
        public void PlaceDoor(Point start)
        {
            //figure out if they meant to put door on left or top of tile
            var left = start.X % Gc.TILE_SIZE;
            var top = start.Y % Gc.TILE_SIZE;
            start = start.ConvertToTilePosition(Gc.TILE_SIZE);

            var d = new Door
            {
                Line = new Line
                {
                    Stroke = new SolidColorBrush(Colors.DarkGray),
                    StrokeThickness = 5,
                    X1 = start.X,
                    X2 = start.X,
                    Y1 = start.Y,
                    Y2 = start.Y
                }
            };

            if (left < top) // they were closer to left side of tile
            {
                d.Rotation = 90;
                d.Line.Y2 += Gc.TILE_SIZE;
            }
            else // else they were closer to top, or were equal distances at which point I'm putting it here because the user is an indecisive bastard
            {
                d.Rotation = 0;
                d.Line.X2 += Gc.TILE_SIZE;
            }

            Canvas.SetZIndex(d.Line, DOOR_LAYER);
            Map.Children.Add(d.Line);
            DoorList.Add(d);
        }
Example #2
0
        public void PlaceWall(Point start, Point end)
        {
            start = start.ConvertToTilePosition(Gc.TILE_SIZE);
            end = end.ConvertToTilePosition(Gc.TILE_SIZE);
            var b = new Bounds(start, end).KeepBoundsWidthOf1();

            //hack to add last tile of wall since walls start at 0,0 but should go the full length of last tile
            if (b.LowerX == b.UpperX) b.UpperY += Gc.TILE_SIZE;
            else if (b.LowerY == b.UpperY) b.UpperX += Gc.TILE_SIZE;

            var w = new Wall
            {
                Line = new Line
                {
                    X1 = b.LowerX,
                    Y1 = b.LowerY,
                    X2 = b.UpperX,
                    Y2 = b.UpperY,
                    Stroke = new SolidColorBrush(Colors.Gray),
                    StrokeThickness = 3
                },
            };

            Canvas.SetZIndex(w.Line, WALL_LAYER);
            Map.Children.Add(w.Line);
            WallList.Add(w);
        }
Example #3
0
        public void RemoveExistingTilesBetween(Point start, Point end)
        {
            var tiles = Map.Children.OfType<Rectangle>()
                .Where(x => x != selectionRectangle)
                .Where(x => x.WithinBounds(start.ConvertToTilePosition(Gc.TILE_SIZE), end.ConvertToTilePosition(Gc.TILE_SIZE)))
                .ToList();

            for (int i = tiles.Count() - 1; i >= 0; i--)
            {
                Map.Children.Remove(tiles[i]);
                TileList.Remove(TileList.FirstOrDefault(x => x.Rectangle == tiles[i]));
            }
        }
Example #4
0
        public void PlaceTile(Point start, Point end)
        {
            start = start.ConvertToTilePosition(Gc.TILE_SIZE);
            end = end.ConvertToTilePosition(Gc.TILE_SIZE);

            RemoveExistingTilesBetween(start, end);
            PlaceTilesBetween(start, end);
        }