private void initializeBoard() { int boardSize = r_GameEngine.GetBoardSize(); for (int i = 0; i < boardSize; i++) { for (int j = 0; j < boardSize; j++) { PictureBoxTile newPictureBoxTile = new PictureBoxTile(new Coordinate(i, j)); newPictureBoxTile.Click += tile_Click; Controls.Add(newPictureBoxTile); } } }
private void tile_Click(object sender, EventArgs e) { PictureBoxTile clickedTile = sender as PictureBoxTile; bool legalMove = false; if (m_SelectedSoldier != null) { Move move = new Move(m_SelectedSoldier.Coordinate, clickedTile.Coordinate); legalMove = r_GameEngine.TryMove(move); if (r_GameEngine.IsGameEnded()) { OnGameEnded(); } } if (!legalMove) { clickedTile.BlinkRed(); } }