/// <summary> /// Chooses the next cell that the characters can traverse on, given the previous cell. This function chooses which /// cells are traversable in the level grid. /// </summary> /// <param name="gridNavigator">The navigator which chooses the next traversable cell.</param> private Cell ChooseNextTraversableCell(Cell cell, GridNavigator gridNavigator) { // Stores the directions in which the path may NOT go. That is, if this constant is // set to 'NavigationDirection.Left', for instance, the next cell CANNOT be to the left // of the current one. The illegal directions are set to the direction of each of the // cell's occupied neighbours. That is, if the cell above this one is occupied, the next // traversable cell cannot be above the current one, since it is already occupied. NavigationDirection illegalDirections = GetOccupiedNeighbours(cell); // Choose a direction in which to move to define the next cell in the golden path NavigationDirection pathDirection = gridNavigator.ChooseDirection(illegalDirections); // Advance to the next cell in which to continue the current path cell = GridNavigator.Advance(cell, pathDirection); // Return the next traversable cell to define in the level grid return(cell); }