public void PlaceTile(Tile tile, FitProperties properties)
        {
            var spaceToRemove  = spaces.FirstOrDefault(s => s.X == properties.Point.X && s.Y == properties.Point.Y);
            var spacesAndTiles = spaces.Concat(playedTiles.Cast <Space>()).ToList();
            var northSpace     = spacesAndTiles.FirstOrDefault(s => s.X == properties.Point.X && s.Y == properties.Point.Y + 1);
            var eastSpace      = spacesAndTiles.FirstOrDefault(s => s.X == properties.Point.X + 1 && s.Y == properties.Point.Y);
            var southSpace     = spacesAndTiles.FirstOrDefault(s => s.X == properties.Point.X && s.Y == properties.Point.Y - 1);
            var westSpace      = spacesAndTiles.FirstOrDefault(s => s.X == properties.Point.X - 1 && s.Y == properties.Point.Y);

            if (northSpace == null)
            {
                northSpace = new Space {
                    SouthTile = tile, X = properties.Point.X, Y = properties.Point.Y + 1
                };
                spaces.Add(northSpace);
            }

            if (eastSpace == null)
            {
                eastSpace = new Space {
                    WestTile = tile, X = properties.Point.X + 1, Y = properties.Point.Y
                };
                spaces.Add(eastSpace);
            }

            if (southSpace == null)
            {
                southSpace = new Space {
                    NorthTile = tile, X = properties.Point.X, Y = properties.Point.Y - 1
                };
                spaces.Add(southSpace);
            }

            if (westSpace == null)
            {
                westSpace = new Space {
                    EastTile = tile, X = properties.Point.X - 1, Y = properties.Point.Y
                };
                spaces.Add(westSpace);
            }

            northSpace.SouthTile = tile;
            eastSpace.WestTile   = tile;
            southSpace.NorthTile = tile;
            westSpace.EastTile   = tile;

            playedTiles.Add(tile);
            tile.X        = properties.Point.X;
            tile.Y        = properties.Point.Y;
            tile.Rotation = properties.Rotation;

            if (spaceToRemove != null)
            {
                spaces.Remove(spaceToRemove);
            }
        }
Exemple #2
0
 public IEnumerable<Follower> GetFollowers(FitProperties selectedPossibility)
 {
     var angle = 0.5 * Math.PI * (4.0 - (int)selectedPossibility.Rotation);
     return followerPositions.Select(p => new Follower(Math.Cos(angle) * p.X + Math.Sin(angle) * p.Y, Math.Cos(angle) * p.Y - Math.Sin(angle) * p.X, p.FeatureType, p.FeatureNumber));
 }