Esempio n. 1
0
        private List<FloorPlan> FacadeGenerator(float width, int floorCount, bool hasAttic, bool hasEntrances = false,
            bool longFacade = false)
        {
            List<PanelSize> panelSizes = SplitWallIntoPanels(width);
            int panelCount = panelSizes.Count;

            var floors = new List<FloorPlan>(floorCount + 1);
            int entrances = (int) (width/10 - 1);
            int entranceCount = 1;
            int entranceIndex = panelCount*entranceCount/(entrances + 1);

            for (var i = 0; i < floorCount + 1; i++)
            {
                var floorPlan = new FloorPlan {height = i == 0 ? SocleHeight : FloorHeight};
                floors.Add(floorPlan);

                for (var j = 0; j < panelCount; j++)
                {
                    // On socle floor we have entrances and socle panels
                    if (i == 0)
                    {
                        if (hasEntrances && j == entranceIndex && entranceCount <= entrances)
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type = PanelType.Entrance,
                                size = panelSizes[j],
                                height = FloorHeight
                            });
                            entranceCount++;
                            entranceIndex = panelCount*entranceCount/(entrances + 1);
                        }
                        else
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type = PanelType.Socle,
                                size = panelSizes[j],
                                height = SocleHeight
                            });
                        }
                    }
                    // On first floor we decorate entrances with entrance walls,
                    // place windows on long facades and regular walls on short facades
                    else if (i == 1)
                    {
                        if (floors[0].panels[j].type == PanelType.Entrance)
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type = PanelType.EntranceWall,
                                size = panelSizes[j],
                                height = FloorHeight,
                                heightOffset = FloorHeight - SocleHeight
                            });
                        }
                        else if (longFacade)
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type = PanelType.Window,
                                size = panelSizes[j],
                                height = FloorHeight
                            });
                        }
                        else
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type = PanelType.Wall,
                                size = panelSizes[j],
                                height = FloorHeight
                            });
                        }
                    }
                    // On second floor and upper we repeat layout of the first floor
                    else
                    {
                        floorPlan.panels.Add(new Panel(floors[i - 1].panels[j]));
                    }

                    // Entrance-type panel on the last floor should have special model
                    if (i == floorCount && (floors[i - 1].panels[j].type == PanelType.Entrance ||
                                            floors[i - 1].panels[j].type == PanelType.EntranceWall))
                    {
                        floorPlan.panels[j].type = PanelType.EntranceWallLast;
                        floorPlan.panels[j].height = SocleHeight;
                        floorPlan.panels[j].heightOffset = FloorHeight - SocleHeight;
                    }
                }

                // Short facade can have windows, but their positions should have horizontal symmetry
                if (i == 1 && !longFacade)
                {
                    // Iterate from corner to center of facade and replace walls with windows
                    for (int j = 0; j <= panelCount/2; j++)
                    {
                        if (j != 0 && j != panelCount - 1 && RandomE.Chance(0.5f))
                        {
                            floorPlan.panels[j].type = PanelType.Window;
                            floorPlan.panels[panelCount - 1 - j].type = PanelType.Window;
                        }
                    }
                }

                // Symmetrically replace windows with balconies
                if (i == 2)
                {
                    for (int j = 0; j <= panelCount/2; j++)
                    {
                        if (floorPlan.panels[j].type == PanelType.Window &&
                            floorPlan.panels[panelCount - 1 - j].type == PanelType.Window && RandomE.Chance(0.5f))
                        {
                            floorPlan.panels[j].type = PanelType.Balcony;
                            floorPlan.panels[panelCount - 1 - j].type = PanelType.Balcony;
                        }
                    }
                }
            }

            // Attach attic on top
            if (hasAttic)
            {
                var floorPlan = new FloorPlan {height = AtticHeight};
                floors.Add(floorPlan);

                for (var i = 0; i < panelCount; i++)
                {
                    floorPlan.panels.Add(new Panel
                    {
                        type = PanelType.Attic,
                        size = panelSizes[i],
                        height = AtticHeight
                    });
                }
            }

            return floors;
        }
Esempio n. 2
0
        private static List <FloorPlan> FacadeGenerator(float width, int floorCount, bool hasAttic,
                                                        bool hasEntrances = false,
                                                        bool longFacade   = false)
        {
            List <PanelSize> panelSizes = SplitWallIntoPanels(width);
            int panelCount = panelSizes.Count;

            var floors        = new List <FloorPlan>(floorCount + 1);
            int entrances     = (int)(width / 10 - 1);
            int entranceCount = 1;
            int entranceIndex = panelCount * entranceCount / (entrances + 1);

            for (var i = 0; i < floorCount + 1; i++)
            {
                var floorPlan = new FloorPlan {
                    height = i == 0 ? SocleHeight : FloorHeight
                };
                floors.Add(floorPlan);

                for (var j = 0; j < panelCount; j++)
                {
                    // On socle floor we have entrances and socle panels
                    if (i == 0)
                    {
                        if (hasEntrances && j == entranceIndex && entranceCount <= entrances)
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type   = PanelType.Entrance,
                                size   = panelSizes[j],
                                height = FloorHeight
                            });
                            entranceCount++;
                            entranceIndex = panelCount * entranceCount / (entrances + 1);
                        }
                        else
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type   = PanelType.Socle,
                                size   = panelSizes[j],
                                height = SocleHeight
                            });
                        }
                    }
                    // On first floor we decorate entrances with entrance walls,
                    // place windows on long facades and regular walls on short facades
                    else if (i == 1)
                    {
                        if (floors[0].panels[j].type == PanelType.Entrance)
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type         = PanelType.EntranceWall,
                                size         = panelSizes[j],
                                height       = FloorHeight,
                                heightOffset = FloorHeight - SocleHeight
                            });
                        }
                        else if (longFacade)
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type   = PanelType.Window,
                                size   = panelSizes[j],
                                height = FloorHeight
                            });
                        }
                        else
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type   = PanelType.Wall,
                                size   = panelSizes[j],
                                height = FloorHeight
                            });
                        }
                    }
                    // On second floor and upper we repeat layout of the first floor
                    else
                    {
                        floorPlan.panels.Add(new Panel(floors[i - 1].panels[j]));
                    }

                    // Entrance-type panel on the last floor should have special model
                    if (i == floorCount && (floors[i - 1].panels[j].type == PanelType.Entrance ||
                                            floors[i - 1].panels[j].type == PanelType.EntranceWall))
                    {
                        floorPlan.panels[j].type         = PanelType.EntranceWallLast;
                        floorPlan.panels[j].height       = SocleHeight;
                        floorPlan.panels[j].heightOffset = FloorHeight - SocleHeight;
                    }
                }

                // Short facade can have windows, but their positions should have horizontal symmetry
                if (i == 1 && !longFacade)
                {
                    // Iterate from corner to center of facade and replace walls with windows
                    for (int j = 0; j <= panelCount / 2; j++)
                    {
                        if (j != 0 && j != panelCount - 1 && RandomE.Chance(0.5f))
                        {
                            floorPlan.panels[j].type = PanelType.Window;
                            floorPlan.panels[panelCount - 1 - j].type = PanelType.Window;
                        }
                    }
                }

                // Symmetrically replace windows with balconies
                if (i == 2)
                {
                    for (int j = 0; j <= panelCount / 2; j++)
                    {
                        if (floorPlan.panels[j].type == PanelType.Window &&
                            floorPlan.panels[panelCount - 1 - j].type == PanelType.Window && RandomE.Chance(0.5f))
                        {
                            floorPlan.panels[j].type = PanelType.Balcony;
                            floorPlan.panels[panelCount - 1 - j].type = PanelType.Balcony;
                        }
                    }
                }
            }

            // Attach attic on top
            if (hasAttic)
            {
                var floorPlan = new FloorPlan {
                    height = AtticHeight
                };
                floors.Add(floorPlan);

                for (var i = 0; i < panelCount; i++)
                {
                    floorPlan.panels.Add(new Panel
                    {
                        type   = PanelType.Attic,
                        size   = panelSizes[i],
                        height = AtticHeight
                    });
                }
            }

            return(floors);
        }
Esempio n. 3
0
        private List <FloorPlan> FacadeGenerator(float width, int floorCount, bool hasAttic, bool hasEntrances = false,
                                                 bool longFacade = false)
        {
            var panelSizes = PanelSizes(width);
            int panelCount = panelSizes.Count;

            var floors        = new List <FloorPlan>(floorCount + 1);
            int entrances     = (int)(width / 10 - 1);
            var entranceCount = 1;
            var entranceIndex = panelCount * entranceCount / (entrances + 1);

            for (var i = 0; i < floorCount + 1; i++)
            {
                var floorPlan = new FloorPlan {
                    height = i == 0 ? SocleHeight : FloorHeight
                };
                floors.Add(floorPlan);

                for (var j = 0; j < panelCount; j++)
                {
                    if (i == 0)
                    {
                        if (hasEntrances && j == entranceIndex && entranceCount <= entrances)
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type   = PanelType.Entrance,
                                size   = panelSizes[j],
                                height = FloorHeight
                            });
                            entranceCount++;
                            entranceIndex = panelCount * entranceCount / (entrances + 1);
                        }
                        else
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type   = PanelType.Socle,
                                size   = panelSizes[j],
                                height = SocleHeight
                            });
                        }
                    }
                    else if (i == 1)
                    {
                        if (floors[0].panels[j].type == PanelType.Entrance)
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type         = PanelType.EntranceWall,
                                size         = panelSizes[j],
                                height       = FloorHeight,
                                heightOffset = FloorHeight - SocleHeight
                            });
                        }
                        else if (longFacade)
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type   = PanelType.Window,
                                size   = panelSizes[j],
                                height = FloorHeight
                            });
                        }
                        else
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type   = PanelType.Wall,
                                size   = panelSizes[j],
                                height = FloorHeight
                            });
                        }
                    }
                    else
                    {
                        floorPlan.panels.Add(new Panel(floors[i - 1].panels[j]));
                    }

                    if (i == floorCount && (floors[i - 1].panels[j].type == PanelType.Entrance ||
                                            floors[i - 1].panels[j].type == PanelType.EntranceWall))
                    {
                        floorPlan.panels[j].type         = PanelType.EntranceWallLast;
                        floorPlan.panels[j].height       = SocleHeight;
                        floorPlan.panels[j].heightOffset = FloorHeight - SocleHeight;
                    }
                }

                if (i == 1 && !longFacade)
                {
                    for (int j = 0; j <= panelCount / 2; j++)
                    {
                        if (j != 0 && j != panelCount - 1 && RandomE.Chance(0.5f))
                        {
                            floorPlan.panels[j].type = PanelType.Window;
                            floorPlan.panels[panelCount - 1 - j].type = PanelType.Window;
                        }
                    }
                }

                if (i == 2)
                {
                    for (int j = 0; j <= panelCount / 2; j++)
                    {
                        if (floorPlan.panels[j].type == PanelType.Window &&
                            floorPlan.panels[panelCount - 1 - j].type == PanelType.Window && RandomE.Chance(0.5f))
                        {
                            floorPlan.panels[j].type = PanelType.Balcony;
                            floorPlan.panels[panelCount - 1 - j].type = PanelType.Balcony;
                        }
                    }
                }
            }

            if (hasAttic)
            {
                var floorPlan = new FloorPlan {
                    height = AtticHeight
                };
                floors.Add(floorPlan);

                for (var i = 0; i < panelCount; i++)
                {
                    floorPlan.panels.Add(new Panel
                    {
                        type   = PanelType.Attic,
                        size   = panelSizes[i],
                        height = AtticHeight
                    });
                }
            }

            return(floors);
        }
Esempio n. 4
0
        private List<FloorPlan> FacadeGenerator(float width, int floorCount, bool hasAttic, bool hasEntrances = false,
            bool longFacade = false)
        {
            var panelSizes = PanelSizes(width);
            int panelCount = panelSizes.Count;

            var floors = new List<FloorPlan>(floorCount + 1);
            int entrances = (int) (width/10 - 1);
            var entranceCount = 1;
            var entranceIndex = panelCount*entranceCount/(entrances + 1);

            for (var i = 0; i < floorCount + 1; i++)
            {
                var floorPlan = new FloorPlan {height = i == 0 ? SocleHeight : FloorHeight};
                floors.Add(floorPlan);

                for (var j = 0; j < panelCount; j++)
                {
                    if (i == 0)
                    {
                        if (hasEntrances && j == entranceIndex && entranceCount <= entrances)
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type = PanelType.Entrance,
                                size = panelSizes[j],
                                height = FloorHeight
                            });
                            entranceCount++;
                            entranceIndex = panelCount*entranceCount/(entrances + 1);
                        }
                        else
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type = PanelType.Socle,
                                size = panelSizes[j],
                                height = SocleHeight
                            });
                        }
                    }
                    else if (i == 1)
                    {
                        if (floors[0].panels[j].type == PanelType.Entrance)
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type = PanelType.EntranceWall,
                                size = panelSizes[j],
                                height = FloorHeight,
                                heightOffset = FloorHeight - SocleHeight
                            });
                        }
                        else if (longFacade)
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type = PanelType.Window,
                                size = panelSizes[j],
                                height = FloorHeight
                            });
                        }
                        else
                        {
                            floorPlan.panels.Add(new Panel
                            {
                                type = PanelType.Wall,
                                size = panelSizes[j],
                                height = FloorHeight
                            });
                        }
                    }
                    else
                    {
                        floorPlan.panels.Add(new Panel(floors[i - 1].panels[j]));
                    }

                    if (i == floorCount && (floors[i - 1].panels[j].type == PanelType.Entrance ||
                                            floors[i - 1].panels[j].type == PanelType.EntranceWall))
                    {
                        floorPlan.panels[j].type = PanelType.EntranceWallLast;
                        floorPlan.panels[j].height = SocleHeight;
                        floorPlan.panels[j].heightOffset = FloorHeight - SocleHeight;
                    }
                }

                if (i == 1 && !longFacade)
                {
                    for (int j = 0; j <= panelCount/2; j++)
                    {
                        if (j != 0 && j != panelCount - 1 && RandomE.Chance(0.5f))
                        {
                            floorPlan.panels[j].type = PanelType.Window;
                            floorPlan.panels[panelCount - 1 - j].type = PanelType.Window;
                        }
                    }
                }

                if (i == 2)
                {
                    for (int j = 0; j <= panelCount/2; j++)
                    {
                        if (floorPlan.panels[j].type == PanelType.Window &&
                            floorPlan.panels[panelCount - 1 - j].type == PanelType.Window && RandomE.Chance(0.5f))
                        {
                            floorPlan.panels[j].type = PanelType.Balcony;
                            floorPlan.panels[panelCount - 1 - j].type = PanelType.Balcony;
                        }
                    }
                }
            }

            if (hasAttic)
            {
                var floorPlan = new FloorPlan {height = AtticHeight};
                floors.Add(floorPlan);

                for (var i = 0; i < panelCount; i++)
                {
                    floorPlan.panels.Add(new Panel
                    {
                        type = PanelType.Attic,
                        size = panelSizes[i],
                        height = AtticHeight
                    });
                }
            }

            return floors;
        }