Esempio n. 1
0
        /// <summary>
        /// Производит атаку на ячейку
        /// </summary>
        private void AtackCell()
        {
            Cell selectedCell = GetSelectedCell();
            Cell clickedCell  = GetFocusedCell();

            if (selectedCell != null && clickedCell != null)
            {
                if (clickedCell?.Owner == GetActivePlayer())
                {
                    _currentGameState = GameStates.Select;
                    selectedCell.DisactiveCell();
                    clickedCell.ActiveCell();
                }
                else
                {
                    _moveRunner.Move(selectedCell, clickedCell, GetActivePlayer());
                    if (IsFinishedGame())
                    {
                        _currentGameState = GameStates.Finished;
                        FinishedEvent?.Invoke(this, EventArgs.Empty);
                    }
                }
            }

            PaintEvent?.Invoke();
            _button.CallPaintEvent();
        }
Esempio n. 2
0
        /// <summary>
        /// Выбирает ячейку
        /// </summary>
        private void SelectCell()
        {
            Cell clickedCell = GetFocusedCell();

            UnselectAllCells();
            if (clickedCell != null)
            {
                if (clickedCell?.Owner == GetActivePlayer())
                {
                    clickedCell.ActiveCell();
                    _currentGameState = GameStates.Atack;
                }
            }

            PaintEvent?.Invoke();
        }