예제 #1
0
        private static MovesSetting GetMovesSetting()
        {
            var defaultFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "moves.txt");

            var          path    = GetFilePath(defaultFile, "Move");
            MovesSetting setting = null;

            if (path != null)
            {
                setting = new MovesSetting(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);
            }
        }