//connect 2 rivers into 1 public void ConnectWith(RiverInfo river2) { if (riverPath[0].EqualsCoordinates(river2.riverPath[0])) { river2.riverPath.RemoveAt(0); riverPath.Reverse(); riverPath.AddRange(river2.riverPath); //riverPath.Reverse(); } else if (GetLastVertex().EqualsCoordinates(river2.riverPath[0])) { river2.riverPath.RemoveAt(0); riverPath.AddRange(river2.riverPath); } else if (riverPath[0].EqualsCoordinates(river2.GetLastVertex())) { riverPath.RemoveAt(0); riverPath.Reverse(); river2.riverPath.Reverse(); riverPath.AddRange(river2.riverPath); riverPath.Reverse(); } else if (GetLastVertex().EqualsCoordinates(river2.GetLastVertex())) { river2.riverPath.RemoveAt(river2.riverPath.Count - 1); river2.riverPath.Reverse(); riverPath.AddRange(river2.riverPath); } else { Debug.Log("RIVERS DONT HAVE COMMON END POINT"); } //reachTop = reachTop || river2.reachTop; //reachRight = reachRight || river2.reachRight; //reachBot = reachBot || river2.reachBot; //reachLeft = reachLeft || river2.reachLeft; }
/// <summary> /// generates rivers starting from given river's starting and ending point /// operation is processed only if points are in visible terrain and not on border /// => meaning that terrain has been moved and river isn't complete /// </summary> public void GenerateConnectingRiver(RiverInfo river) { Vertex startPoint = river.riverPath[0]; if (ftm.IsInDefinedTerrain(startPoint) && !ftm.IsOnBorder(startPoint)) { Area restrictArea = fmc.CalculateRestrictedArea(startPoint); List<Direction> reachedSides = new List<Direction>(); reachedSides.Add(fmc.GetOppositeDirection(startPoint.side)); RiverInfo startRiver = frp.GetRiverFrom(startPoint, reachedSides, restrictArea, river, river.gridStep, true); if(startRiver.riverPath.Count == 0) { ShowErrorMessage("connecting river failed \n" + startRiver.errorMessage); } frd.DistortPath(startRiver.riverPath, startRiver.gridStep/3, startRiver.gridStep); river.ConnectWith(startRiver); startPoint.side = Direction.none; } Vertex endPoint = river.GetLastVertex(); if (ftm.IsInDefinedTerrain(endPoint) && !ftm.IsOnBorder(endPoint)) { Area restrictArea = fmc.CalculateRestrictedArea(endPoint); List<Direction> reachedSides = new List<Direction>(); reachedSides.Add(fmc.GetOppositeDirection(endPoint.side)); RiverInfo endRiver = frp.GetRiverFrom(endPoint, reachedSides, restrictArea, river, river.gridStep, true); if (endRiver.riverPath.Count == 0) { ShowErrorMessage("connecting river failed \n" + endRiver.errorMessage); } frd.DistortPath(endRiver.riverPath, endRiver.gridStep / 3, endRiver.gridStep); river.ConnectWith(endRiver); endPoint.side = Direction.none; } frd.DigRiver(river); }