Esempio n. 1
0
        private void DrawDistrictPattern()
        {
            if (!ShowDistricts || CityConfiguration.DistrictLayer.Generator.GeneratedPolygons == null)
            {
                return;
            }


            if (ShowDistrictCenters)
            {
                foreach (var p in CityConfiguration.DistrictLayer.Polygons)
                {
                    Gizmos.color = Color.red;
                    Gizmos.DrawSphere(p.Center, 0.005f);
                    foreach (var point in p.Points)
                    {
                        Gizmos.color = Color.black;
                        Gizmos.DrawSphere(point, 0.003f);
                    }
                }
            }


            if (ShowDistrictRegions)
            {
                foreach (var region in CityConfiguration.DistrictLayer.Regions)
                {
                    foreach (var tr in region.Triangles)
                    {
                        Gizmos.color = Color.blue;
                        Gizmos.DrawSphere(tr.Center, 0.003f);

                        Gizmos.color = Color.green;

                        Gizmos.DrawLine(tr.P1, tr.P2);
                        Gizmos.DrawLine(tr.P2, tr.P3);
                        Gizmos.DrawLine(tr.P3, tr.P1);
                    }
                }
            }

            foreach (var district in CityConfiguration.DistrictLayer.Generator.GeneratedPolygons)
            {
                if (ShowDistrictIndexes)
                {
                    Handles.Label(district.Center, district.Index.ToString());
                }
                foreach (var e in district.Edges)
                {
                    if (ShowDistrictIndexes)
                    {
                        Handles.Label(e.Origin, e.Origin.Index.ToString());
                        Handles.Label(e.Center, e.Index.ToString());
                    }

                    if (ShowDistrictBorders)
                    {
                        Gizmos.color = Color.black;
                        if (e.Other() == null)
                        {
                            Gizmos.color = Color.red;
                        }
                        ExtendedGizmos.DrawLineDirection(((Vector2)e.Origin).MovePointInDirectionOfPoint(district.Center, 0.02f),
                                                         ((Vector2)e.Destination).MovePointInDirectionOfPoint(district.Center, 0.02f));
                    }
                }

                if (ShowDistrictBounds)
                {
                    // Draw Bounding Box of district
                    Gizmos.color = Color.green;

                    Gizmos.DrawLine(district.BoundingBox.BottomLeft(), district.BoundingBox.BottomRight());
                    Gizmos.DrawLine(district.BoundingBox.TopLeft(), district.BoundingBox.TopRight());

                    Gizmos.DrawLine(district.BoundingBox.BottomLeft(), district.BoundingBox.TopLeft());
                    Gizmos.DrawLine(district.BoundingBox.BottomRight(), district.BoundingBox.TopRight());
                }
            }
        }
Esempio n. 2
0
        private void DrawNeighborhoodPatterns()
        {
            if (!ShowNeighborhoods || CityConfiguration.DistrictLayer.PolygonIdToDistrictMap == null)
            {
                return;
            }

            foreach (var d in CityConfiguration.DistrictLayer.PolygonIdToDistrictMap.Values)
            {
                if (d == null || d.Neigborhoods == null)
                {
                    continue;
                }

                // Show neighborhood Sites
                //foreach (var site in CityConfiguration.NeighborhoodLayer.Sites)
                //{
                //    Gizmos.color = Color.white;
                //    Gizmos.DrawSphere(site, 0.005f);
                //}

                foreach (var n in d.Neigborhoods)
                {
                    if (ShowNeighborhoodIndexes)
                    {
                        Handles.Label(n.Center, n.Index.ToString());
                    }
                    int cnt = 0;

                    foreach (var e in n.Edges)
                    {
                        if (ShowNeighborhoodIndexes)
                        {
                            Handles.Label(e.Origin + Vector2.down * Mathf.Sin(e.Origin.Index + 10 * cnt) / 500, e.Origin.Index.ToString());
                            Handles.Label(e.Center + Vector2.down * Mathf.Sin(e.Index + 10 * cnt) / 500, e.Index.ToString());
                        }

                        if (ShowNeighborhoodBorders)
                        {
                            Gizmos.color = Color.black;

                            if (e.Other() == null)
                            {
                                Gizmos.color = Color.red;
                            }

                            ExtendedGizmos.DrawLineDirection(((Vector2)e.Origin).MovePointInDirectionOfPoint(n.Center, 0.02f),
                                                             ((Vector2)e.Destination).MovePointInDirectionOfPoint(n.Center, 0.02f));
                        }
                        cnt++;
                    }

                    if (ShowNeighborhoodBounds)
                    {
                        // Draw Bounding Box of the neighborhood
                        Gizmos.color = Color.green;

                        Gizmos.DrawLine(n.BoundingBox.BottomLeft(), n.BoundingBox.BottomRight());
                        Gizmos.DrawLine(n.BoundingBox.TopLeft(), n.BoundingBox.TopRight());

                        Gizmos.DrawLine(n.BoundingBox.BottomLeft(), n.BoundingBox.TopLeft());
                        Gizmos.DrawLine(n.BoundingBox.BottomRight(), n.BoundingBox.TopRight());
                    }
                }
            }
        }