Exemple #1
0
    void Update()
    {
        if (action == 0)
        {
            return;
        }

        if (action == 1)
        {
            if (!end)
            {
                end = Input.GetKeyDown(KeyCode.F5);
            }

            if (!step)
            {
                step = Input.GetKeyDown(KeyCode.F10);
            }

            if (!step && !end)
            {
                return;
            }

            if (end)
            {
                RoadNetworkGenerator.EndInteractiveGeneration(ref context);
                action = 0;
            }
            else
            {
                if (!RoadNetworkGenerator.InteractiveGenerationStep(speed, ref context))
                {
                    action = 0;
                }
            }

            foreach (Segment segment in context.segments)
            {
                RoadNetworkTraversal.PreOrder(segment, Visitor, mask, ref visited);
            }

            RemoveIcons();
            if (context.debugData.intersections.Count > 0 ||
                context.debugData.snaps.Count > 0 ||
                context.debugData.intersectionsRadius.Count > 0)
            {
                foreach (Vector2 intersection in context.debugData.intersections)
                {
                    iconGOs.Add(CreateIcon(intersection, iconSize, downscaleFactor, z, intersectionIcon));
                }
                foreach (Vector2 snap in context.debugData.snaps)
                {
                    iconGOs.Add(CreateIcon(snap, iconSize, downscaleFactor, z, snapIcon));
                }
                foreach (Vector2 intersectionRadius in context.debugData.intersectionsRadius)
                {
                    iconGOs.Add(CreateIcon(intersectionRadius, iconSize, downscaleFactor, z, intersectionRadiusIcon));
                }
                context.debugData.intersections.Clear();
                context.debugData.snaps.Clear();
                context.debugData.intersectionsRadius.Clear();
            }

            step = false;
        }
    }
Exemple #2
0
    void Update()
    {
        if (action == 0)
        {
            return;
        }

        if (action == 1)
        {
            if (!end)
            {
                end = Input.GetKeyDown(KeyCode.F5);
            }

            if (!step)
            {
                step = Input.GetKeyDown(KeyCode.F10);
            }

            if (!step && !end)
            {
                return;
            }

            if (end)
            {
                RoadNetworkGenerator.EndInteractiveGeneration(ref context);
                action = 0;
            }
            else
            {
                if (!RoadNetworkGenerator.InteractiveGenerationStep(speed, ref context))
                {
                    action = 0;
                }
            }

            // ---

            var roadGeometry = RoadNetworkGeometryBuilder.Build(
                scale,
                Config.highwaySegmentWidth * scale,
                Config.streetSegmentWidth * scale,
                lengthStep,
                context.segments,
                ((displayHighways) ? RoadNetworkTraversal.HIGHWAYS_MASK : 0) | ((displayStreets) ? RoadNetworkTraversal.STREETS_MASK : 0)
                );
            CreateRoadMesh(roadGeometry);

            // ---

            RemoveIcons();
            if (context.debugData.intersections.Count > 0 ||
                context.debugData.snaps.Count > 0 ||
                context.debugData.intersectionsRadius.Count > 0)
            {
                foreach (Vector2 intersection in context.debugData.intersections)
                {
                    iconGOs.Add(CreateIcon(intersection, iconSize, scale, z, intersectionIcon));
                }
                foreach (Vector2 snap in context.debugData.snaps)
                {
                    iconGOs.Add(CreateIcon(snap, iconSize, scale, z, snapIcon));
                }
                foreach (Vector2 intersectionRadius in context.debugData.intersectionsRadius)
                {
                    iconGOs.Add(CreateIcon(intersectionRadius, iconSize, scale, z, intersectionRadiusIcon));
                }
                context.debugData.intersections.Clear();
                context.debugData.snaps.Clear();
                context.debugData.intersectionsRadius.Clear();
            }

            step = false;
        }
    }