コード例 #1
0
        public static bool Create(AntRunner.Models.Map map, MapTile tile)
        {
            var checker = new WallRender(map, tile.Item);
            var sides   = new[]
            {
                new KeyValuePair <TileSide, MapTile>(TileSide.Left, checker.Left(tile, true)), new KeyValuePair <TileSide, MapTile>(TileSide.Right, checker.Right(tile, true)),
                new KeyValuePair <TileSide, MapTile>(TileSide.Bottom, checker.Down(tile, true)), new KeyValuePair <TileSide, MapTile>(TileSide.Top, checker.Up(tile, true))
            }.Where(x => x.Value != null).ToArray();

            if (sides.All(x => x.Value.Item == tile.Item))
            {
                var first = sides.Select(x => x.Value).FirstOrDefault(x => x.Processed != null);
                if (first != null)
                {
                    first.Processed.AddTile(tile);
                    return(false);
                }
                return(true);
            }

            var group = sides.FirstOrDefault(x => x.Value.Item == tile.Item && x.Value.Processed != null);

            if (group.Value == null)
            {
                return(true);
            }

            var startTile = sides.FirstOrDefault(x => x.Value.Item != tile.Item);

            group.Value.Processed.Combine(tile, startTile.Key);
            return(false);
        }
コード例 #2
0
        public WallRender(AntRunner.Models.Map map, Item wallType)
        {
            _map      = map;
            _wallType = wallType;
            if (wallType == Item.SteelWall)
            {
                _path = new Path
                {
                    StrokeThickness = 1,
                    Fill            = Brushes.DimGray,
                    Stroke          = Brushes.Black
                };
            }
            else
            {
                _path = new Path
                {
                    StrokeThickness = 1,
                    Fill            = Brushes.Brown,
                    Stroke          = Brushes.Black
                };
            }

            _geometry = new CombinedGeometry {
                GeometryCombineMode = GeometryCombineMode.Exclude, Geometry2 = new GeometryGroup()
            };
            _path.Data = _geometry;
        }