コード例 #1
0
        /// <summary>
        /// Xử lý gói dữ liệu dạng SocketData
        /// </summary>
        /// <param name="data"></param>
        private void DataHandling(SocketData data)
        {
            switch (data.Command)
            {
            case (int)SocketCommand.NOTIFY:

                break;

            case (int)SocketCommand.NEW_GAME:
                this.Invoke((MethodInvoker)(() =>
                {
                    NewGame();
                    panelBoard.Enabled = false;
                    CoolDownTimer.Stop();
                }));
                break;

            case (int)SocketCommand.SEND_POINT:
                this.Invoke((MethodInvoker)(() =>
                {
                    pbCoolDown.Value = 0;
                    panelBoard.Enabled = true;
                    CoolDownTimer.Start();
                    gh.OtherPlayerMark(data.Point);
                }));
                break;

            //case (int)SocketCommand.END_GAME:
            //    MessageBox.Show("Bạn đã thua");
            //    break;

            case (int)SocketCommand.TIME_OUT:
                EndGame();
                MessageBox.Show("Bạn đã thắng!");
                break;

            case (int)SocketCommand.QUIT:
                CoolDownTimer.Stop();
                MessageBox.Show("Đối thủ đã thoát ra!");
                break;

            default:
                break;
            }
            Listen();
        }
コード例 #2
0
 /// <summary>
 /// Hàm xử lý kết thúc game
 /// </summary>
 public void EndGame()
 {
     CoolDownTimer.Stop();
     panelBoard.Enabled = false;
 }
コード例 #3
0
 private void newGameToolStripMenuItem_Click(object sender, EventArgs e)
 {
     CoolDownTimer.Stop();
     NewGame();
     socket.Send(new SocketData((int)SocketCommand.NEW_GAME, ""));
 }