Esempio n. 1
0
        public void Go()
        {
            bool   proceed  = true;
            int    inputkey = 1;
            Parser parser   = new Parser();
            int    state    = FirstStart;

            while (proceed)
            {
                if (state == FirstStart)
                {
                    // alleen bij start een doolhofnummer vragen
                    _outputview.ShowGameStart();
                    inputkey = _inputview.AskForMazeNumber();

                    if (inputkey == KeyCancel)
                    {
                        proceed = false;
                    }
                }

                if (proceed)
                {
                    try
                    {
                        _maze = parser.LoadMaze(inputkey);
                        _mazeViewController.MazeViewed = _maze;
                        _outputview.ShowBoardState(_maze);
                        state = RunAround();
                        if (state == IsMazeSolved)
                        {
                            _outputview.ShowMazeSolved();
                            state = FirstStart;
                        }
                        else if (state == KeyCancel)
                        {
                            state = FirstStart;
                        }
                    }
                    catch (Exception_MazeIncorrectFileFormat e)
                    {
                        string message = String.Concat("doolhof", inputkey, " bevat een fout: \n\t", e.ToString());
                        _outputview.ShowError(message);
                    }

                    catch (System.IO.FileNotFoundException e)
                    {
                        string message = String.Concat("doolhof", inputkey, " niet gevonden: \n\t", e.FileName);
                        _outputview.ShowError(message);
                    }

                    catch (System.IO.DirectoryNotFoundException e)
                    {
                        string message = String.Concat("doolhof", inputkey, " niet gevonden: \n\t", e.Message);
                        _outputview.ShowError(message);
                    }
                }
            }
        }