Exemplo n.º 1
0
        private void startButton_Click(object sender, EventArgs e)
        {
            if (!gameRunning)
            {
                textBox4.Enabled = false;
                checkBox1.Enabled = false;
                LoadCard temp = new LoadCard();
                temp.moveWindow();
                gameRunning = true;
                int limit1 = 90;
                int limit2 = 60;
                int limit3 = 55;
                bool aggre = aggreButton1.Checked;
                bool safe = safeButton1.Checked;
                if (aggre)
                {
                    limit1 -= 5;
                    limit2 -= 5;
                    limit3 -= 5;
                }
                else if (safe)
                {
                    limit2 += 5;
                    limit3 += 5;
                }

                Thread infinite = new Thread(() =>
                {    // Get the color of my panel
                while (true)
                    {
                        Thread.Sleep(2000);

                    //PushBullet
                    if (checkBox1.Checked == true && textBox4.Text.Length != 0)
                        {
                            if (receivePushBullet(textBox4.Text) == 1)
                            {
                                gameRunning = false;
                                enableTextBox4("");
                            }
                        }

                        if (checkMyTurn()) // Checks the turn
                    {
                            setMyTurn("My turn");

                        //lock (_locker) {
                        // {
                        loadCardFill();
                        // setTextBox3("" + this.oddsGrid1.PlayerWins);
                        if (this.oddsGrid1.PlayerWins >= limit1)
                            {
                            // if (checkPixelColor(thirdButtonX, thirdButtonY) == Color.FromArgb(255, 70, 24, 10))
                            // {
                            mouseClick(thirdButtonX, thirdButtonY);
                                mouseClick(thirdButtonX, thirdButtonY - 10);
                                mouseClick(100, firstButtonY);
                            // }
                            // else if(checkPixelColor(secondButtonX, secondButtonY) == Color.FromArgb(255, 70, 24, 10))
                            // {
                            mouseClick(secondButtonX, secondButtonY);
                                mouseClick(secondButtonX, secondButtonY - 10);
                                mouseClick(100, firstButtonY);
                            //  }
                        }
                            else if (this.oddsGrid1.PlayerWins >= limit2 || (this.Board.Text == "" && this.oddsGrid1.PlayerWins >= limit3))
                            {
                            // if (checkPixelColor(secondButtonX, secondButtonY) == Color.FromArgb(255, 70, 24, 10))
                            //  {
                            mouseClick(secondButtonX, secondButtonY);
                                mouseClick(secondButtonX, secondButtonY - 10);
                                mouseClick(100, firstButtonY);
                            //   }
                            //  else
                            //  {
                            mouseClick(thirdButtonX, thirdButtonY);
                                mouseClick(thirdButtonX, thirdButtonY - 10);
                                mouseClick(100, firstButtonY);
                            // }
                        }
                            else
                            {
                            // if (checkPixelColor(firstButtonX, firstButtonY) == Color.FromArgb(255, 70, 24, 10))
                            // {
                            mouseClick(firstButtonX, firstButtonY);
                                mouseClick(firstButtonX, firstButtonY - 10);
                                mouseClick(100, firstButtonY);
                            //  }
                        }
                        // }
                    }
                        else
                        {
                            setMyTurn("Not my turn");
                        }

                        if (!gameRunning)
                        {
                            enableTextBox4("");
                            setMyTurn("Not Running");
                            break;

                        }

                    }

                });
                infinite.Start();

            }
        }
Exemplo n.º 2
0
        /*
        private void loadCard_Click(object sender, EventArgs e)
        {

            loadCardFill();
            int i = checkCurrentBoard();
            textBox3.Text = "" + i;
            //this.PocketCards.Text = poket;

            //this.Board.Text = board;

        }
        */
        private void loadCardFill()
        {
            LoadCard lc = new LoadCard();
            Queue<String> result = new Queue<string>();
            // Thread FirstThread = new Thread(() => {
              //  do
               // {
                result = lc.loadCardFromFile();
                this.setText_Hand(result.Dequeue());

            //  } while (result.Peek().Length == checkCurrentBoard() * 3);
            //  int current = checkCurrentBoard();
            int sss = result.Peek().Length;
            this.setText_Board(result.Dequeue());
            //int i = result.Peek().Length;
            //    if (current * 3 == result.Peek().Length)
            //  {

            //   }
            //poket = result.Dequeue();
            //board = result.Dequeue();

            //  });
            //  FirstThread.Start();
        }