예제 #1
0
        private void Start(string cmd)
        {
            bool checkResult = CheckMessage(cmd);


            if (checkResult)
            {
                //string cmd = cmbCommand.Text;

                //txtShowInfo.Text += TcpPost.Start(cmd, txtAdress.Text, txtPort.Text) + Environment.NewLine;
                rCmd = TcpPost.Start(cmd, txtAdress.Text, txtPort.Text);
            }


            //表示已经连接上
            if (!rCmd.Contains("无法连接"))
            {
                isContinue          = true;
                isOnline            = true;
                timer_state.Enabled = true;

                MessageBox.Show("连接成功,祝您游戏愉快!");
            }
            else
            {
                isOnline = false;
                MessageBox.Show("未找到服务端!");
            }
        }
예제 #2
0
        private void Start()
        {
            bool checkResult = CheckMessage();

            if (checkResult)
            {
                string cmd = cmbCommand.Text;

                txtShowInfo.Text += TcpPost.Start(cmd, txtAdress.Text, txtPort.Text) + Environment.NewLine;
            }
        }
예제 #3
0
        private void timer2_Tick(object sender, EventArgs e)
        {
            //timer2.Enabled = false;
            // 电脑跑一张 到位了
            if (ComputerPB[ComputerPB_Index].Location.X - pictureBox2.Location.X < 10)
            {
                timer2.Enabled = false; // 电脑一次只跑一张
                ComputerScore[ComputerPB_Index] = CardSeq[Card_No];
                // 将目标牌 秀出
                if (ComputerPB_Index == 0) // 电脑第一张不翻牌
                {
                    ComputerPB[ComputerPB_Index].Image = Properties.Resources.cardback_blue_lace;
                    Card_No++; // 发牌序 加一
                }
                else
                {
                    ComputerPB[ComputerPB_Index].Image = imageList1.Images[CardSeq[Card_No]];
                    Card_No++;                                                                              // 发牌序 加一
                }
                pictureBox2.Location = new Point(pictureBox1.Location.X + 10, pictureBox1.Location.Y - 10); // 瞬間將發牌 移回 原處 障眼法

                // 要决定 是否 电脑要叫停
                int sum  = 0;
                int aces = 0;
                for (int i = 0; i <= ComputerPB_Index; i++)
                {
                    sum = sum + weight[ComputerScore[i]]; // 全部加总 Ace 算 1 分
                    if (weight[ComputerScore[i]] == 1)
                    {
                        aces++;                                // 有几张 Ace
                    }
                }
                computerSum  = sum; //电脑总数(包含第一张)所有Ace算1分
                computerAces = aces;

                rCmd = TcpPost.Start(toCmd(), txtAdress.Text.ToString(), txtPort.Text.ToString());
                //MessageBox.Show(rCmd);

                /*
                 * if(!rCmd.Contains("无法连接"))
                 *  if (Convert.ToInt32(rCmd) == 0)
                 *  {
                 *      ComputerPB_Active = false;
                 *  }
                 */
                /*
                 * if (sum > 16) ComputerPB_Active = false; // 电脑 不再 要牌
                 * else if (aces >= 1 && sum > 7) ComputerPB_Active = false;
                 * else if (aces >= 2 && sum == 3) ComputerPB_Active = false;
                 */

                if (sum > 21)
                {
                    ComputerDie         = true;
                    isContinue          = false;
                    timer_state.Enabled = true;
                    return;
                }

                if (MyPB_Active)                                  // 如果玩家 還未 叫停
                {
                    MyTurn = true;                                // 開始 玩家時間
                }
                else if (ComputerPB_Active)                       // 否則  玩家已經叫停 且 电脑 尚未叫停
                {
                    if (ComputerPB_Index < ComputerPB.Length - 1) // 还有空间
                    {
                        ComputerPB_Index++;
                        timer2.Enabled = true;  // 电脑再跑一張
                    }
                }

                if (timer2.Enabled)
                {
                    toolStripStatusLabel1.Text = "电脑叫牌";
                }
                else
                {
                    if (ComputerPB_Active)
                    {
                        toolStripStatusLabel1.Text = "等玩家";
                    }
                    else
                    {
                        toolStripStatusLabel1.Text = "电脑叫停,等玩家";
                    }
                }
            }
            else // 持續移動
            {
                pictureBox2.Location = new Point(pictureBox2.Location.X + 10, pictureBox2.Location.Y);
            }
        }