Exemple #1
0
        public void ProcessRightClick(CustomizedButton button)
        {
            if (button.Text == @"X")
            {
                button.Text = "";
                _controller.FlagsChanged(++FlagsCount);

                if (button.Value == "BOMB")
                {
                    BombsCount++;
                }
            }
            else
            {
                button.Text = @"X";
                _controller.FlagsChanged(--FlagsCount);

                if (button.Value == "BOMB")
                {
                    BombsCount--;
                }
            }

            CheckIfWin();
        }
Exemple #2
0
        private void ProcessBomb(CustomizedButton button)
        {
            button.Text    = @"B";
            button.Enabled = false;

            ShowBombs();

            _controller.GameOver();
        }
Exemple #3
0
        public void ProcessLeftClick(CustomizedButton button)
        {
            if (button.Value == "BOMB")
            {
                ProcessBomb(button);
            }
            else
            {
                ProcessSafeButton(button);
            }

            CheckIfWin();
        }
Exemple #4
0
        private void ProcessSafeButton(CustomizedButton button)
        {
            var x = button.Location.X / ButtonSize - 1;
            var y = button.Location.Y / ButtonSize - 1;

            button.Text      = button.Value;
            button.Enabled   = false;
            button.IsVisited = true;

            if (button.Value == "0")
            {
                OpenEmptyNeighbours(x, y);
            }
        }
Exemple #5
0
        private void CreateMap()
        {
            GameButtons = new CustomizedButton[MapBounds, MapBounds];

            for (var i = 0; i < GameButtons.GetLength(0); i++)
            {
                for (var j = 0; j < GameButtons.GetLength(1); j++)
                {
                    GameButtons[i, j] = new CustomizedButton
                    {
                        IsVisited = false
                    };
                    GameButtons[i, j].SetBounds((i + 1) * ButtonSize, (j + 1) * ButtonSize, ButtonSize, ButtonSize);
                }
            }

            _controller.AddMapButton(GameButtons);
        }