Пример #1
0
        private static BoardSetting GetBoardSetting()
        {
            var defaultFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "board.txt");

            var          path    = GetFilePath(defaultFile, "Board Setting");
            BoardSetting setting = null;

            if (path != null)
            {
                setting = new BoardSetting(path);;
                setting.Load();
            }
            return(setting);
        }
Пример #2
0
        private void Button2_Click(object sender, EventArgs e)
        {
            try
            {
                movesSetting = new MovesSetting(moveFile);
                movesSetting.Load();



                boardSetting = new BoardSetting(boardFile);
                boardSetting.Load();
                current = boardSetting.StartPoint;
                CreateBoard(boardSetting);

                this.Width  = boardSetting.BoardWithd * 52 + 220;
                this.Height = boardSetting.BoardHeight * 52 + 40 + panel1.Height;
                this.Update();
                game = Engine.Game
                       .Create(boardSetting.BoardWithd, boardSetting.BoardHeight)
                       .LayMine(boardSetting.Mines)
                       .SetExitPoint(boardSetting.ExitPoint)
                       .AddTurtle(boardSetting.StartPoint, boardSetting.Direction, this.G_TurtleStatusChanged);

                ThreadPool.QueueUserWorkItem(s => Play());
            }
            catch (InvalidSettingException ex)
            {
                StringBuilder strb = new StringBuilder();
                strb.AppendLine(ex.Message);
                foreach (var item in ex.Errors)
                {
                    strb.AppendLine(item.ToString());
                }
                ShowError(strb.ToString());
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }