void SolveMazeInternal(Maze.SolveType type) { MazeSettings.CurrentSolveType = type; Init(WorkerType.Solve); }
void worker_DoWork(object sender, DoWorkEventArgs e) { WorkerType type = (WorkerType)Enum.ToObject(typeof(WorkerType), e.Argument); var dict = new Dictionary<string, object>(); dict["type"] = type; e.Result = dict; switch (type) { case WorkerType.Gen: { var maze = new Maze(display.Size); ShowStatus("正在生成地图"); maze.GenerateMaze(); MazeSettings.CurrentMaze = maze; } break; case WorkerType.Solve: { var maze = MazeSettings.CurrentMaze; if (maze == null) throw new Exception("地图未生成"); ShowStatus("正在搜索路径"); dict["result"] = maze.SolveMaze(); } break; } }
void GeneratMazeInternal(Maze.MazeType type) { if (MazeSettings.CurrentMazeType == type) MazeSettings.CurrentSeed = new Random().Next(); MazeSettings.CurrentMazeType = type; Init(WorkerType.Gen); }