Example #1
0
 void SolveMazeInternal(Maze.SolveType type)
 {
     MazeSettings.CurrentSolveType = type;
     Init(WorkerType.Solve);
 }
Example #2
0
        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;
            }
        }
Example #3
0
        void GeneratMazeInternal(Maze.MazeType type)
        {
            if (MazeSettings.CurrentMazeType == type)
                MazeSettings.CurrentSeed = new Random().Next();

            MazeSettings.CurrentMazeType = type;
            Init(WorkerType.Gen);
        }