// Move in the specified direction private void MoveInDir(MoveDirs2D moveDir, CellArray2D_BitArray theMap) { // Setting theMap[] vals to true when wall is broken down switch (moveDir) { case MoveDirs2D.UpX: currCellX += 1; theMap[currCellX, currCellY, 0] = true; break; case MoveDirs2D.DownX: theMap[currCellX, currCellY, 0] = true; currCellX -= 1; break; case MoveDirs2D.UpY: currCellY += 1; theMap[currCellX, currCellY, 1] = true; break; case MoveDirs2D.DownY: theMap[currCellX, currCellY, 1] = true; currCellY -= 1; break; } }
// Move in the opposite direction as the previous direction of movement private void MoveInReverseDir(MoveDirs2D previousDir) { switch (previousDir) { case MoveDirs2D.UpX: currCellX--; break; case MoveDirs2D.DownX: currCellX++; break; case MoveDirs2D.UpY: currCellY--; break; case MoveDirs2D.DownY: currCellY++; break; } }
// Returns false if moveDir goes out of bounds or toward a visited cell private bool CanMoveInDir(MoveDirs2D moveDir, CellArray2D_BitArray theMap, CellArray2D_BitArray isVisited) { switch (moveDir) { case MoveDirs2D.UpX: return(!(currCellX + 1 >= theMap.sizeX) && !(isVisited[currCellX + 1, currCellY, 0])); case MoveDirs2D.DownX: return(!(currCellX - 1 < 0) && !(isVisited[currCellX - 1, currCellY, 0])); case MoveDirs2D.UpY: return(!(currCellY + 1 >= theMap.sizeY) && !(isVisited[currCellX, currCellY + 1, 0])); case MoveDirs2D.DownY: return(!(currCellY - 1 < 0) && !(isVisited[currCellX, currCellY - 1, 0])); } return(false); }