private void btn_Click(object sender, EventArgs e) { Button btn = sender as Button; if (btn.BackgroundImage != null) { return; // Nếu ô đã được đánh thì ko cho đánh lại } btn.BackgroundImage = ListPlayers[CurrentPlayer].Symbol; StkUndoStep.Push(new PlayInfo(GetButtonCoordinate(btn), CurrentPlayer, btn.BackgroundImage)); StkRedoStep.Clear(); CurrentPlayer = CurrentPlayer == 1 ? 0 : 1; ChangePlayer(); if (playerClicked != null) { playerClicked(this, new BtnClickEvent(GetButtonCoordinate(btn))); } if (IsEndGame()) { EndGame(); } if (!(IsAI) && playMode == 3) { StartAI(); } IsAI = false; }
public void OtherPlayerClicked(Point point) { Button btn = MatrixPositions[point.Y][point.X]; if (btn.BackgroundImage != null) { return; // Nếu ô đã được đánh thì ko cho đánh lại } btn.BackgroundImage = ListPlayers[CurrentPlayer].Symbol; StkUndoStep.Push(new PlayInfo(GetButtonCoordinate(btn), CurrentPlayer, btn.BackgroundImage)); StkRedoStep.Clear(); CurrentPlayer = CurrentPlayer == 1 ? 0 : 1; ChangePlayer(); if (IsEndGame()) { EndGame(); } }