예제 #1
37
파일: Form1.cs 프로젝트: lafeldtb/Winter16
 public Form1()
 {
     minesShowing = false;
     InitializeComponent();
     this.Hide();
     g = new Game();
     gameBoard = new Button[][]
     {
         new Button[] {button0, button1, button2, button3, button4, button5, button6, button7, button8, button9},
         new Button[] {button10, button11, button12, button13, button14, button15, button16, button17, button18, button19},
         new Button[] {button20, button21, button22, button23, button24, button25, button26, button27, button28, button29},
         new Button[] {button30, button31, button32, button33, button34, button35, button36, button37, button38, button39},
         new Button[] {button40, button41, button42, button43, button44, button45, button46, button47, button48, button49},
         new Button[] {button50, button51, button52, button53, button54, button55, button56, button57, button58, button59},
         new Button[] {button60, button61, button62, button63, button64, button65, button66, button67, button68, button69},
         new Button[] {button70, button71, button72, button73, button74, button75, button76, button77, button78, button79},
         new Button[] {button80, button81, button82, button83, button84, button85, button86, button87, button88, button89},
         new Button[] {button90, button91, button92, button93, button94, button95, button96, button97, button98, button99},
     };
     updateBoard();
     this.Show();
     foreach (var button in Controls.OfType<Button>())
     {
         button.Click += button_Click;
     }
 }
예제 #2
25
        public Square( int xPos, int yPos, Game.Difficulty d )
        {
            if( Program.random( (int)d ) == 0 )
            {
                isMine = true;
            }

            this.FlatStyle = FlatStyle.Popup;
            this.Appearance = Appearance.Button;
            this.AutoCheck = false;
            this.BackColor = Color.Green;

            this.Width = SIZE;
            this.Height = SIZE;
            this.Left = xPos * SIZE;
            this.Top = yPos * SIZE;
            this.Font = new System.Drawing.Font( new System.Drawing.FontFamily( System.Drawing.Text.GenericFontFamilies.SansSerif ), 10, System.Drawing.FontStyle.Bold );

            _X = xPos;
            _Y = yPos;

            ContextMenuStrip = new ContextMenuStrip( );

            EventHandler ehDig = new EventHandler( Menu_Dig );
            ContextMenuStrip.Items.Add( new ToolStripMenuItem( "Dig", Minesweeper.Properties.Resources.down, ehDig ) );

            EventHandler ehFlag = new EventHandler( Menu_Flag );
            ContextMenuStrip.Items.Add( new ToolStripMenuItem( "Flag", Minesweeper.Properties.Resources.flag, ehFlag ) );

            EventHandler ehTrigger = new EventHandler( Menu_TriggerSurrounding );
            ContextMenuStrip.Items.Add( new ToolStripMenuItem( "Trigger Surroundings", Minesweeper.Properties.Resources.redled, ehTrigger ) );

            ContextMenuStrip.Items[ 2 ].Enabled = false;
        }
예제 #3
1
 void startNewGame( Game.Difficulty difficulty )
 {
     startNewGame( difficulty, 20, 15 );
 }
예제 #4
0
        public Square(Game game, int rowIdx, int colIdx)
        {
            sqr = new Button();
            sqr.BackgroundImage = Minesweeper.Properties.Resources.ButtonUp;
            sqr.Width = 16;
            sqr.Height = 16;
            sqr.FlatStyle = FlatStyle.Flat;
            sqr.Location = new Point(rowIdx * sqr.Width,  //Location requires (x,y)
                colIdx * sqr.Height);          //(row number * 16, column number * 16) to keep simple with "blocks" not coords

            game.panel.Controls.Add(sqr);
        }
예제 #5
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            Game game;

            switch (difficulty)
            {
                case 0:
                    game = new Game(this.pnlMines, 9, 9, 10);
                    game.DrawGrid();
                    break;
                case 1:
                    game = new Game(this.pnlMines, 16, 16, 40);
                    game.DrawGrid();
                    break;
                case 2:
                    game = new Game(this.pnlMines, 16, 16, 40);
                    game.DrawGrid();
                    break;
            }
        }
예제 #6
0
        private void newGame()
        {
            timer.Stop();
            time = 0;
            this.labelTime.Text = "0";
            settings = new Settings();

            if (!first)
            {
                foreach (CellElement cell in currentGame.Grid)
                {
                    this.Controls.Remove(cell);
                }
            }
            else
            {
                first = false;
            }

            RW.getDifficulty();
            GameDifficulty currentGameDifficulty = new GameDifficulty(RW.Difficulty);
            this.Height = Global.bottomPanel + (currentGameDifficulty.sideY + 1) * Global.constMultiplier + Global.startingY;
            this.Width = (currentGameDifficulty.sideX + 1) * Global.constMultiplier + Global.startingX;
            settings.difficultyLevelChanged += new NewGameHandler(newGame);
            this.labelBombs.Location = new Point(Global.bombsLocConst, currentGameDifficulty.sideY * Global.constMultiplier + Global.startingY + Global.locConst);
            this.labelTime.Location = new Point(Global.timeLocConst, currentGameDifficulty.sideY * Global.constMultiplier + Global.startingY + Global.locConst);
            currentGame = new Game(currentGameDifficulty);

            foreach (CellElement cell in currentGame.Grid)
            {
                this.Controls.Add(cell);
            }

            if (RW.Difficulty == 0)
                labelBombs.Text = "10";

            else if (RW.Difficulty == 1)
                labelBombs.Text = "40";

            else
                labelBombs.Text = "99";
        }
예제 #7
0
 void startNewGame( Game.Difficulty difficulty, int width, int height )
 {
     time = 0;
     toolStripContainer1.ContentPanel.Controls.Clear( );
     Game game = new Game( width, height, difficulty );
     toolStripContainer1.ContentPanel.Controls.Add( game );
     game.Dock = DockStyle.Fill;
     game.t.Tick += new EventHandler( t_Tick );
     toolStripLabel1.Text = game.mineCount( ).ToString( ) + " mines.";
 }