public void TriangulateRoads(IHexCell cell, IHexMesh roadsMesh)
        {
            if (cell.HasRoads)
            {
                var cellHash = NoiseGenerator.SampleHashGrid(cell.AbsolutePositionXZ);

                var directionsWithRoad = EnumUtil.GetValues <HexDirection>().Where(
                    direction => Grid.HasNeighbor(cell, direction) && Grid.GetNeighbor(cell, direction).HasRoads
                    ).ToList();

                while (directionsWithRoad.Any())
                {
                    var startDirection = directionsWithRoad.First();

                    directionsWithRoad.Remove(startDirection);

                    BezierSpline spline;

                    if (directionsWithRoad.Any())
                    {
                        var endDirection = GetBestDirection(startDirection, directionsWithRoad, cellHash);

                        directionsWithRoad.Remove(endDirection);

                        spline = BuildSplineBetween(cell, startDirection, endDirection);
                    }
                    else
                    {
                        spline = BuildSplineToCenter(cell, startDirection);
                    }

                    RenderSpline(spline, roadsMesh);
                }
            }
        }
示例#2
0
        private void AddRiverToCell(
            IHexCell cell, HexDirection direction, RiverFlow flow, HashSet <IHexCell> cellsAdjacentToRiver
            )
        {
            RiverCanon.AddRiverToCell(cell, direction, flow);

            cellsAdjacentToRiver.Add(cell);

            if (Grid.HasNeighbor(cell, direction))
            {
                cellsAdjacentToRiver.Add(Grid.GetNeighbor(cell, direction));
            }
        }