public static UEdge2i FromDirection(Vec2i origin, Directions_Ortho_2D direction) { if (direction.IsSingle() == false) { throw new System.Exception("direction is not single!"); } else if (direction == Directions_Ortho_2D.None) { throw new System.Exception("direction is None!"); } if (direction == Directions_Ortho_2D.U) { return(new UEdge2i(origin, origin.To_Up())); } if (direction == Directions_Ortho_2D.D) { return(new UEdge2i(origin, origin.To_Down())); } if (direction == Directions_Ortho_2D.L) { return(new UEdge2i(origin, origin.To_Left())); } if (direction == Directions_Ortho_2D.R) { return(new UEdge2i(origin, origin.To_Right())); } return(new UEdge2i()); }
public static Edge2i FromDirection(Directions_Ortho_2D direction) { if (direction.IsSingle() == false) { throw new System.Exception("direction is not single!"); } else if (direction == Directions_Ortho_2D.None) { throw new System.Exception("direction is None!"); } if (direction == Directions_Ortho_2D.U) { return(new Edge2i(new Vec2i(0, 0), Vec2i.up)); } if (direction == Directions_Ortho_2D.D) { return(new Edge2i(new Vec2i(0, 0), Vec2i.down)); } if (direction == Directions_Ortho_2D.L) { return(new Edge2i(new Vec2i(0, 0), Vec2i.left)); } if (direction == Directions_Ortho_2D.R) { return(new Edge2i(new Vec2i(0, 0), Vec2i.right)); } return(new Edge2i()); }
public static bool IsCell_DeadEnd(this PM_Maze maze, int x, int y) { Directions_Ortho_2D cellDirections = maze.Q_Cell_Directions(x, y); if (cellDirections.IsSingle() || cellDirections == Directions_Ortho_2D.None) { return(true); } return(false); }
public static int NumLeafNodes(this PM_Maze maze) { int width = maze.Q_Width(); int height = maze.Q_Height(); int num = 0; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { Directions_Ortho_2D dir = maze.Q_Cell_Directions(x, y); if (dir.IsSingle()) { num++; } } } return(num); }