Esempio n. 1
0
    private Coordinate CalculateNextRiverSegment(Coordinate coord)
    {
        if (IsValidTile(coord))
        {
            var sourceDir    = FindTile(coord).RiverConnections.First();
            var possibleDirs = HexGridHelper.GetOpposite3(sourceDir);
            var candidates   = HexGridHelper.FindNeighbours(coord, possibleDirs);
            //.Where(x => FindTile(x).Height == HeightOfRivers);

            if (candidates.Any())
            {
                var segment = candidates.PickOne();
                var tries   = 10;
                while (!IsPossibleExtension(segment) && candidates.Any() && tries > 0)
                {
                    candidates = candidates.Where(x => !x.Equals(segment));
                    segment    = candidates.PickOne();
                    tries--;
                }

                if (tries > 0 && candidates.Any() && FindTile(segment) != null && FindTile(segment).Feature == TileFeature.None)
                {
                    var dir = HexGridHelper.FindDirectionToNeighbour(coord, segment);
                    FindTile(coord).RiverConnections.Add(dir);
                    return(segment);
                }
            }
        }

        return(invalid);
    }
Esempio n. 2
0
    public void ShowFragments()
    {
        roadFragments = this.GetComponent <EdgeManager>();
        roadFragments.HideAll();

        foreach (var n in Neighbours)
        {
            roadFragments.GetEdge(HexGridHelper.FindDirectionToNeighbour(this.TileRef.Coord, n.TileRef.Coord))
            .SetActive(true);
        }
    }
Esempio n. 3
0
    private Compass GetRiverOrigin(Coordinate coord)
    {
        if (IsValidTile(coord))
        {
            var adj = HexGridHelper.FindAllNeighbours(coord).Where(x => FindTile(x) != null && FindTile(x).Height < HeightOfRivers);
            if (adj.Any())
            {
                return(HexGridHelper.FindDirectionToNeighbour(coord, adj.First()));
            }

            adj = HexGridHelper.FindAllNeighbours(coord).Where(x => FindTile(x) != null && FindTile(x).Feature == TileFeature.River);
            return(HexGridHelper.FindDirectionToNeighbour(coord, adj.First()));
        }

        return(Compass.East);
    }