private static int[] GenerateRowObstacles_Improved1(ObstacleBank obstacleBank, int challengeLevel, bool[] paths) { //Debug.Log("GenerateRowObstacles_Improved1 challengLevel=" + challengeLevel); if (challengeLevel > CHALLENGE_LEVEL_MAX) { challengeLevel = CHALLENGE_LEVEL_MAX; } bool[] guaranteedPaths = new bool[Constants.ROW_WIDTH]; for (int i = 0; i < Constants.ROW_WIDTH; i++) { if (IsPath(paths, i)) { int startI = i; while (IsPath(paths, i + 1)) { i++; } guaranteedPaths[Random.Range(startI, i + 1)] = true; } } List <int> obstacles = new List <int>(); for (int i = 0; i < Constants.ROW_WIDTH; i++) { if (IsPath(guaranteedPaths, i)) { obstacles.Add(Constants.EMPTY_TILE_INDEX); } else { float obstacleChance = CHALLENGE_LEVEL_MULTIPLIER * challengeLevel + BASE_OBSTACLE_CHANCE; //Debug.Log("obstacleChance=" + obstacleChance); if (IsPath(paths, i)) { if (RollPercentageChance(obstacleChance)) { obstacles.Add(Random.Range(0, obstacleBank.GetMaxObstacleId() + 1)); } else { obstacles.Add(Constants.EMPTY_TILE_INDEX); } } else { if (RollPercentageChance(NO_PATH_OBSTACLE_CHANCE_MULTIPLIER * obstacleChance)) { obstacles.Add(Random.Range(0, obstacleBank.GetMaxObstacleId() + 1)); } else { obstacles.Add(Constants.EMPTY_TILE_INDEX); } } } } return(obstacles.ToArray()); }
// Pure Random Obstacle Placement with a challenge level input public static int[] GenerateRowObstacles_RandomWithChallenge(ObstacleBank obstacleBank, int challengeLevel) { List <int> obstacles = new List <int>(); for (int i = 0; i < Constants.ROW_WIDTH; i++) { if (RollPercentageChance(10f + challengeLevel)) { obstacles.Add(Random.Range(0, obstacleBank.GetMaxObstacleId() + 1)); } else { obstacles.Add(Constants.EMPTY_TILE_INDEX); } } return(obstacles.ToArray()); }
public static int[] GenerateRowObstacles_Dynamic(ObstacleBank obstacleBank) { List <int> obstacles = new List <int>(); for (int i = 0; i < Constants.ROW_WIDTH; i++) { obstacles.Add(Constants.EMPTY_TILE_INDEX); } int numObstacles = Random.Range(1, 3); while (numObstacles > 0) { int obstacleIndex = Random.Range(1, obstacles.Count - 1); if (obstacles[obstacleIndex] == Constants.EMPTY_TILE_INDEX) { obstacles[obstacleIndex] = Random.Range(0, obstacleBank.GetMaxObstacleId()); --numObstacles; } } return(obstacles.ToArray()); }