protected HashSet <Vector2Int> RunRandomWalk(SimpleRandomWalk_SO parameters, Vector2Int pos) { var currentPos = pos; HashSet <Vector2Int> floorPositions = new HashSet <Vector2Int>(); for (int i = 0; i < parameters.iterations; i++) // creating iteration amount of path (random walk) { var path = ProceduralGenerationAlgorithms.SimpleRandomWalk(currentPos, parameters.walkLength); floorPositions.UnionWith(path); if (parameters.startRandomlyEachIteration) { currentPos = floorPositions.ElementAt(UnityEngine.Random.Range(0, floorPositions.Count)); // set the start pos to a random floor pos } } return(floorPositions); }
protected HashSet <Vector2Int> RunRandomWalk(SimpleRandomWalkSO parameters, Vector2Int position) { var currentPosition = position; HashSet <Vector2Int> floorPositions = new HashSet <Vector2Int>(); for (int i = 0; i < parameters.iterations; i++) { var path = ProceduralGenerationAlgorithms.SimpleRandomWalk(currentPosition, parameters.walkLength); floorPositions.UnionWith(path); if (parameters.startRandomlyEachIteration) { currentPosition = floorPositions.ElementAt(Random.Range(0, floorPositions.Count)); } } return(floorPositions); }