public void placeRivers() { int numBridges = ld.width/15 - 1; int numBridgesPlaced = 0; //Where does the river enter and exit the map? (horizontal only ATM) int entrance = (int) Mathf.Clamp(r.getIntInRange(3,ld.height-3),3,ld.height-1); int exit = (int) Mathf.Clamp(r.getIntInRange(3,ld.height-3),3,ld.height-1); Vector2 start = new Vector2(0, entrance); Vector2 end = new Vector2(ld.width-1, exit); // SET UP THE ASTAR astar = new AStar(ld.width, ld.height); astar.clearGrid(); astar.allowDiagonals = true; astar.penalizeDirectionChanges = false; astar.setStartAndEnd(start, end); astar.THE_SEED = (float)ld.seed; astar.COVER_SCATTER = 0.1f; astar.randomCover((int)ld.seed); //The river winds around mountains and other solid stuff if it can GridNode[] thePath = astar.findPath(); int placeABridgeCounter = r.getIntInRange(1,thePath.Length /numBridges+5); for(int i=0; i<thePath.Length; i++) { GridNode node = thePath[i]; int x = (int)node.x; int y = (int)node.y; int yup = (int)Mathf.Max(y-1,0); int xup = (int)Mathf.Min(x+1,ld.width-1); if(numBridgesPlaced <= numBridges && placeABridgeCounter <= 0) { ld.placeTile(x,y,BRIDGE,-1, false); ld.placeTile(x,yup,BRIDGE,-1, false); ld.placeTile(xup,y,BRIDGE,-1, false); ld.placeTile(xup,yup,BRIDGE,-1, false); numBridgesPlaced ++; placeABridgeCounter = r.getIntInRange(1,thePath.Length /numBridges); } else { ld.placeTile(x,y,WATER,-1, true); ld.placeTile(x,yup,WATER,-1, true); ld.placeTile(xup,y,WATER,-1, true); ld.placeTile(xup,yup,WATER,-1, true); } placeABridgeCounter--; }//foreach }