public void MakeSkylineUnavailable(PlacedObject2D theObject) { foreach (var availableSkyline in AvailableSkylines.ToList()) { if (availableSkyline.Y <= theObject.Y) { // Object partially cover skyline below - resize it (left) if (availableSkyline.X < theObject.X && availableSkyline.X2 <= theObject.X2 && availableSkyline.X2 > theObject.X) { availableSkyline.Resize(theObject.X2 - availableSkyline.X2); continue; } // Object completely cover skyline below - remove it if (availableSkyline.X >= theObject.X && availableSkyline.X2 <= theObject.X2) { AvailableSkylines.Remove(availableSkyline); continue; } // Object partially cover skyline below - resize it (right), and move beginning to right if (availableSkyline.X >= theObject.X && availableSkyline.X < theObject.X2 && availableSkyline.X2 > theObject.X2) { availableSkyline.Resize(availableSkyline.X2 - theObject.X2); availableSkyline.Move(theObject.X2); continue; } // Object partially cover skyline below from both size -> resize left, resize and move right if (availableSkyline.X < theObject.X && availableSkyline.X2 > theObject.X2) { var leftSkyline = new Line(availableSkyline.X, theObject.X - availableSkyline.X, availableSkyline.Y); AvailableSkylines.Add(leftSkyline); var rightSkyline = availableSkyline; rightSkyline.Resize(rightSkyline.X2 - theObject.X2); rightSkyline.Move(theObject.X2); } } } }
private void CreateSkylineAtopObject(PlacedObject2D lastPlacedObject) { var newSkyline = new Line(lastPlacedObject.X, lastPlacedObject.Width, lastPlacedObject.Y2); AvailableSkylines.Add(newSkyline); }