private void BuildRoad(GridPoint a, GridPoint b) { List <GridPoint> path = new List <GridPoint>(50); path.Add(a); path.AddRange(GameGen.GridPlacement.ConnectPoints(a, b)); //List<GridPoint> path = GameGen.GridPlacement.ConnectPoints(a, b); //path[path.Count - 1].ChunkRoad = new ChunkRoad(ChunkRoad.RoadType.Paved); GameGen.GridPlacement.GridPoints[path[path.Count - 1].GridPos.x, path[path.Count - 1].GridPos.z].ChunkRoad = new ChunkRoad(path[path.Count - 1].ChunkPos, ChunkRoad.RoadType.Paved); for (int i = 0; i < path.Count - 1; i++) { path[i].ChunkRoad = new ChunkRoad(path[i].ChunkPos, ChunkRoad.RoadType.Paved); GameGen.GridPlacement.GridPoints[path[i].GridPos.x, path[i].GridPos.z].ChunkRoad = new ChunkRoad(path[i].ChunkPos, ChunkRoad.RoadType.Paved); Vec2i v1 = path[i].ChunkPos; Vec2i v2 = path[i + 1].ChunkPos; LineI li = new LineI(v1, v2); foreach (Vec2i v in li.ConnectPoints()) { if (GameGen.TerGen.ChunkBases[v.x, v.z].ChunkFeature is ChunkRiverNode) { GameGen.TerGen.ChunkBases[v.x, v.z].SetChunkFeature(new ChunkRiverBridge(v)); } GameGen.TerGen.ChunkBases[v.x, v.z].SetChunkFeature(new ChunkRoad(v, ChunkRoad.RoadType.Paved)); } } }
private void GenerateRiver(Vec2i start) { Vec2i end = null; for (int i = 1; i < 100; i++) { if (end != null) { break; } for (int j = 0; j < DIRS.Length; j++) { Vec2i pos = start + DIRS[j] * i; if (GameGenerator2.InBounds(pos)) { if (GameGen.TerGen.ChunkBases[pos.x, pos.z].Biome == ChunkBiome.ocean) { end = pos; break; } } } } if (end == null) { return; } LineI li = new LineI(start, end); List <Vec2i> basic = li.ConnectPoints(); float val1 = GenRan.Random(0.1f, 0.001f); float val2 = GenRan.Random(0.1f, 0.001f); int val3 = GenRan.RandomInt(8, 32); int val4 = GenRan.RandomInt(8, 32); for (int i = 0; i < basic.Count; i++) { basic[i] += new Vec2i((int)(val3 * Mathf.Sin(i * val1)), (int)(val4 * Mathf.Sin(i * val2))); } for (int i = 0; i < basic.Count - 1; i++) { Vec2i v1 = basic[i]; Vec2i v2 = basic[i + 1]; LineI i2 = new LineI(v1, v2); foreach (Vec2i v in i2.ConnectPoints()) { GameGen.TerGen.ChunkBases[v.x, v.z].SetChunkFeature(new ChunkRiverNode(v)); } } return; }