コード例 #1
0
ファイル: Area.cs プロジェクト: spacehamster/TownGenerator
        private IEnumerable <Polygon> GetBuildings()
        {
            if (Patch.Equals(_town.Market))
            {
                yield break;
            }

            var   block = GetCityBlock();
            float gridChaos, sizeChaos, minArea;
            Func <Polygon, float> emptyProbabilityFunc;

            GetBuildingSpecs(out gridChaos, out sizeChaos, out emptyProbabilityFunc, out minArea);

            foreach (var building in CreateAlleys(block, minArea, gridChaos, sizeChaos, emptyProbabilityFunc, true))
            {
                Vector2 e1, e2;
                float   len;
                building.GetLongestEdge(out e1, out e2, out len);

                var angle  = GeometryHelpers.Angle(e2 - e1);
                var bounds = building.Rotate(angle).GetBoundingBox();

                var hwRatio = bounds.Height / bounds.Width;
                var whRatio = bounds.Width / bounds.Height;

                if (hwRatio > NarrowBuilding && whRatio > NarrowBuilding)
                {
                    yield return(building);
                }
            }
        }