Пример #1
0
        private void ChessTile_MouseClick(object sender, MouseEventArgs e)
        {
            var selectedTileCoordinates = Tuple.Create(
                ChessBoard.GetCellPosition(sender as Control).Row,
                ChessBoard.GetCellPosition(sender as Control).Column);

            if (e.Button == MouseButtons.Left)
            {
                Game.SelectFigure(selectedTileCoordinates);
            }
            if (e.Button == MouseButtons.Right)
            {
                if (figureList.SelectedIndex == -1 || figureList.SelectedIndex == 0)
                {
                    Game.MoveFigure(selectedTileCoordinates);
                }
                else
                {
                    Game.SpawnFigure(selectedTileCoordinates, figureList.SelectedItem.ToString());
                }
                figureList.ClearSelected();
                RedrawBoard();
                if (Game.GameFinished)
                {
                    MessageBox.Show(Game.PlayerTurn.ToString() + " player lost the game!");
                    ChessBoard.Enabled   = false;
                    PlayerTurnLabel.Text = @"Press ""Start game"" button";
                }
            }
        }