private void backgroundPicture_MouseClick(object i_Sender, MouseEventArgs i_Mouse) { PictureBox sender = i_Sender as PictureBox; int coordinateX = sender.Location.X, coordinateY = sender.Location.Y, squareX = coordinateX - m_StartPositionX, squareY = coordinateY - m_StartPositionY; bool isValidSquare; if (squareX >= 0 && squareY >= 0) { squareX = squareX / m_SquareSizeX; squareY = squareY / m_SquareSizeY; if (squareX < WelcomeForm.m_BoardSize && squareY < WelcomeForm.m_BoardSize) { OnCurrentTurn.Invoke(m_Board.SquareBoard[squareY, squareX], true, m_Board, out isValidSquare); if (isValidSquare) { printChangedBoard(m_Board.SquareBoard); changePlayers(); if (m_Players[m_CurrentPlayerIndex] is AiPlayer) { m_Board = ((AiPlayer)m_Players[1]).AlphaBetaPruning((Board)m_Board.Clone()); printChangedBoard(m_Board.SquareBoard); changePlayers(); } startPlaying(true); } } } }
public GameBL() { server = ServerBL.Instance; server.gameHubProxy.On("StartGame", (string roomId, Board board) => OnStartGame?.Invoke(roomId, board)); server.gameHubProxy.On("GetPlayerColor", (string roomId, CheckerColor color) => OnGetPlayerColor?.Invoke(roomId, color)); server.gameHubProxy.On("GetGameInvitation", (string room, string sender) => OnGameInvitation?.Invoke(room, sender)); server.gameHubProxy.On("DenyGame", (string username) => OnDenyInitation?.Invoke(username)); server.gameHubProxy.On("CurrentTurn", (string roomId, string username) => OnCurrentTurn?.Invoke(roomId, username)); server.gameHubProxy.On("GetUserName", (string userName) => OnGetPlayerName?.Invoke(userName)); server.gameHubProxy.On("UpdateBoard", (string roomId, Board board) => OnBoardUpdate?.Invoke(roomId, board)); server.gameHubProxy.On("DiceResult", (string room, int[] dice) => OnDiceResult?.Invoke(room, dice)); server.gameHubProxy.On("ChangeTurnStatus", (string roomId, TurnStatus turnStatus) => OnTurnStatusChange?.Invoke(roomId, turnStatus)); server.gameHubProxy.On("GameOver", (string roomid, string username) => OnGameOver?.Invoke(roomid, username)); server.gameHubProxy.On("GameClosed", (string room, string sender) => OnGameClosed?.Invoke(room, sender)); }