/// <summary> /// Creates the Tower by stacking a series of Story instances from the Tower Elevation. /// </summary> /// <param name="floors">Desired quantity of stacked Stories to form the Tower. If greater than zero, overrides and resets the current Floors property.</param> /// <param name="storyHeight">Desired typical Story height of the Tower. If greater than zero, overrides and resets the current StoryHeight property.</param> /// <param name="basement">Whether to consider the lowest floor a basement.</param> /// <returns> /// True if the Tower is successfully stacked. /// </returns> public bool Stack() { if (Perimeter == null || storyHeight <= 0.0 || (Floors <= 0.0 && TargetArea <= 0.0)) { return(false); } if (TargetArea > 0.0) { Floors = (int)Math.Ceiling(TargetArea / Perimeter.Area()); } Stories.Clear(); var elevation = Elevation; var slabType = new FloorType(new Guid().ToString(), 0.1); for (int i = 0; i < Floors; i++) { if (elevation + storyHeight > HeightLimit) { break; } var story = new Story() { Color = color, Elevation = elevation, Height = storyHeight, Perimeter = perimeter, SlabType = slabType }; Stories.Add(story); elevation += storyHeight; } if (Stories.Count == 0) { return(false); } return(true); }