Exemplo n.º 1
0
        /// <summary>
        /// right mouse click handler
        /// </summary>
        private void MainView_RightMouseClickHandler(object sender, MinerLogic.MinerPresenter.MouseClickEventArgs e)
        {
            int indexX = e.X / CELL_SIZE;
            int indexY = e.Y / CELL_SIZE;

            if (!_gameManager.IsClosedCell(indexX, indexY)) // if cell is opened - nothing to do
            {
                return;
            }

            Cell newCell = _gameManager.ApplyRightClick(indexX, indexY);

            switch (newCell.CellValue)
            {
            case CellValue.Closed:
                _mainView.SetClosedCell(indexX, indexY);
                break;

            case CellValue.Flag:
                _mainView.SetFlag(indexX, indexY);
                break;

            case CellValue.Question:
                _mainView.SetQuestion(indexX, indexY);
                break;

            default: //already opened cell
                return;
            }
            _mainView.MinesLeft = _gameManager.MinesLeft;
        }
Exemplo n.º 2
0
        /// <summary>
        /// left mouse click handler
        /// </summary>
        private void MainView_LeftMouseClickHandler(object sender, MinerLogic.MinerPresenter.MouseClickEventArgs e)
        {
            int indexX = e.X / CELL_SIZE;
            int indexY = e.Y / CELL_SIZE;

            if (!_gameManager.IsClosedCell(indexX, indexY)) // if cell is opened - nothing to do
            {
                return;
            }
            if (_gameManager.IsFlagCell(indexX, indexY)) //cell with flag - nothing to do
            {
                return;
            }

            Cell[] changedCells = _gameManager.ApplyLeftClick(indexX, indexY);
            ChangeImages(changedCells);

            if (_gameManager.GameState == GameState.Win)
            {
                WinGame();
            }
            else if (_gameManager.GameState == GameState.Loose)
            {
                LooseGame();
            }
        }