private void AddConnectingPoint(Point workingPoint, int currentDirection, List <ConnectingPoint> connectingPointList, ShrunkNode[,] shrunkMap) { int percentage; if (ShrunkWorldBuilder.PointLegit(workingPoint) && stopRoadCount > 0 && shrunkMap[workingPoint.X, workingPoint.Y].IsRoad()) { for (int i = 0; i < 8; i += 2) { int chance = GameController.rnd.Next(0, 100); percentage = percentageTurn; if (currentDirection == i) { percentage = percentageStraight; } if (chance < percentage) { if (CheckIfLandType(AngleStuff.AddPointToDirection(workingPoint, i), shrunkMap, LandType.OPEN)) { int amount = GameController.rnd.Next(minRandomLength, maxRandomLength); connectingPointList.Add(new ConnectingPoint(i, workingPoint, amount)); } } } } }
public bool CheckIfLandType(Point checkPoint, ShrunkNode[,] shrunkMap, LandType landType) { if (ShrunkWorldBuilder.PointLegit(checkPoint)) { return(shrunkMap[checkPoint.X, checkPoint.Y].landType == landType); } return(false); }
private bool CheckIfRoad(Point checkPoint, ShrunkNode[,] shrunkMap) { bool check = false; if (ShrunkWorldBuilder.PointLegit(checkPoint)) { if (shrunkMap[checkPoint.X, checkPoint.Y].IsRoad()) { check = true; } } return(check); }
private int ExtraToReachRoad(ShrunkNode[,] shrunkMap, int directionToTravel, Point expansionPoint) { for (int i = 1; i < extraToReachRoad; i++) { expansionPoint = AngleStuff.AddPointToDirection(expansionPoint, directionToTravel); if (ShrunkWorldBuilder.PointLegit(expansionPoint)) { if (shrunkMap[expansionPoint.X, expansionPoint.Y].IsRoad()) { return(i); } } } return(0); }
private bool IsMoreThanTwoNeighbours(Point expansionPoint, ShrunkNode[,] shrunkMap) { Point workingPoint; int count = 0; for (int i = 0; i < 8; i += 2) { workingPoint = AngleStuff.AddPointToDirection(expansionPoint, i); if (ShrunkWorldBuilder.PointLegit(workingPoint)) { if (shrunkMap[workingPoint.X, workingPoint.Y].IsRoad()) { count++; } } } return(count > 1); }
private bool IsAnyNeighbourRoads(Point point, ShrunkNode[,] shrunkMap) { Point nextPoint; //only checking in four directions; for (int i = 0; i < 8; i += 2) { nextPoint = AngleStuff.AddPointToDirection(point, i); if (ShrunkWorldBuilder.PointLegit(nextPoint)) { if (shrunkMap[nextPoint.X, nextPoint.Y].landType == LandType.CITYROAD || shrunkMap[nextPoint.X, nextPoint.Y].landType == LandType.COUNTRYROAD) { return(true); } } } return(false); }
private bool AddPlot(Point expansionPoint, int direction, ShrunkPlot plot, ShrunkNode[,] shrunkMap) { Point nextPoint = expansionPoint; for (int depth = 1; depth <= plot.maxDepth; depth++) { nextPoint = AngleStuff.AddPointToDirection(nextPoint, direction); if (ShrunkWorldBuilder.PointLegit(nextPoint) && CheckIfLandType(nextPoint, shrunkMap, LandType.OPEN)) { AddCornerPoints(depth, plot, nextPoint); shrunkMap[nextPoint.X, nextPoint.Y].SetLandType(LandType.PLOT); } else { if (depth < 3) { return(false); } } } return(true); }