예제 #1
0
        private void rightMove(Domino domino, PictureBox pbox)
        {
            ImageRotator rotator = new ImageRotator();

            pbox.Location = rightPoint;
            if (domino.First != domino.Second)
            {
                pbox.Image    = rotator.ClockWise(pbox.Image);
                pbox.Location = new Point(pbox.Location.X, vertRY);
                if (domino.First != Right)
                {
                    pbox.Image = rotator.HalfCircle(pbox.Image);
                }
            }
            else
            {
                pbox.Location = new Point(pbox.Location.X, vertRY - 11);
                rotator.ClockWise(pbox.Image);
            }
            Right = (byte)(domino.First + domino.Second - Right);
            if (rightPoint.X > 700 && (downCount > 1 || domino.First != domino.Second) && downCount <= 2)
            {
                if (domino.First == domino.Second)
                {
                    pbox.Image    = rotator.ClockWise(pbox.Image);
                    pbox.Location = new Point(pbox.Location.X - 11, pbox.Location.Y);
                    rotator.ClockWise(pbox.Image);
                }
                else
                {
                    pbox.Image = rotator.CounterClockWise(pbox.Image);
                }
                rightPoint    = new Point(domino.First == domino.Second ? rightPoint.X - 11 : rightPoint.X, vertRY);
                vertRY       += pbox.Size.Height + 3;
                pbox.Location = rightPoint;
                downCount++;
            }
            else if (downCount > 2)
            {
                rightPoint    = new Point(rightPoint.X - pbox.Image.Width - 3, vertRY - 11);
                pbox.Image    = rotator.HalfCircle(pbox.Image);
                pbox.Location = rightPoint;
                if (domino.First == domino.Second)
                {
                    pbox.Location = new Point(pbox.Location.X, pbox.Location.Y - 11);
                }
            }
            else
            {
                rightPoint = new Point(rightPoint.X + pbox.Image.Width + 3, vertRY);
            }
            // (this as Form).Text = downCount.ToString();
            pbox.Size    = pbox.Image.Size;
            label2.Text += '\n' + pbox.Location.ToString() + '-' + pbox.Size.ToString() + '-' + domino.ToString();
        }
예제 #2
0
        private void leftMove(Domino domino, PictureBox pbox)
        {
            ImageRotator rotator = new ImageRotator();

            if (domino.First != domino.Second)
            {
                pbox.Image = rotator.ClockWise(pbox.Image);
                leftPoint  = new Point(leftPoint.X, vertLY);
                if (domino.Second != Left)
                {
                    pbox.Image = rotator.HalfCircle(pbox.Image);
                }
            }
            else
            {
                leftPoint = new Point(leftPoint.X, vertLY - 11);
                //  rotator.ClockWise(pbox.Image);
            }
            if (leftPoint.X < 100 && (upCount > 0 || domino.First != domino.Second) && upCount <= 2)
            {
                pbox.Size  = pbox.Size.Reverse();
                pbox.Image = rotator.CounterClockWise(pbox.Image);
                vertLY    -= pbox.Size.Height + 3;
                leftPoint  = new Point(domino.First == domino.Second ? leftPoint.X - 11 : leftPoint.X, vertLY);
                if (upCount == 0)
                {
                    vertLY -= 32;
                }
                upCount++;
                pbox.Location = leftPoint;
                if (upCount == 3)
                {
                    leftPoint.X += 25;
                }
                if (domino.First == domino.Second)
                {
                    pbox.Image    = rotator.ClockWise(pbox.Image);
                    pbox.Location = new Point(pbox.Location.X - 11, pbox.Location.Y);
                }
                pbox.Size = pbox.Image.Size;
            }
            else if (leftPoint.X < 300 && upCount <= 2 && upCount > 0)
            {
                //vertLY -= 3;
                pbox.Location = new Point(domino.First == domino.Second ? leftPoint.X - 25 : leftPoint.X, vertLY);
                leftPoint     = new Point(leftPoint.X, leftPoint.Y - 3);
                if (domino.First == domino.Second)
                {
                    pbox.Location = new Point(pbox.Location.X, pbox.Location.Y - 11);
                }
            }
            else if (upCount > 2)
            {
                pbox.Image    = rotator.HalfCircle(pbox.Image);
                pbox.Location = leftPoint;
                leftPoint     = new Point(leftPoint.X + pbox.Width + 3, vertLY - 22);

                /*  if (domino.First == domino.Second)
                 *    pbox.Location = new Point(pbox.Location.X, pbox.Location.Y - 11);*/
            }
            else
            {
                leftPoint     = new Point(leftPoint.X - pbox.Image.Width - 3, leftPoint.Y);
                pbox.Location = leftPoint;
            }
            Left         = (byte)(domino.First + domino.Second - Left);
            pbox.Size    = pbox.Image.Size;
            label2.Text += '\n' + pbox.Location.ToString() + '-' + pbox.Size.ToString() + '-' + domino.ToString();
        }
예제 #3
0
        private void PCMove()
        {
            ImageRotator rotator = new ImageRotator();
            bool         move    = false;

            for (int i = 0; i < player2.List.Count; i++)
            {
                if (player2.List[i].Contains(Right))
                {
                    table.Add(player2PictureBox[i]);
                    player2PictureBox[i].Image = player2.List[i].Image;
                    rightMove(player2.List[i], player2PictureBox[i]);
                    player2PictureBox.RemoveAt(i);
                    player2.List.RemoveAt(i);
                    move = true;
                    break;
                }
                else if (player2.List[i].Contains(Left))
                {
                    table.Add(player2PictureBox[i]);
                    player2PictureBox[i].Image = player2.List[i].Image;
                    leftMove(player2.List[i], player2PictureBox[i]);
                    player2PictureBox.RemoveAt(i);
                    player2.List.RemoveAt(i);
                    move = true;
                    break;
                }
                else if (Right + Left == 14)
                {
                    table.Add(player2PictureBox[i]);
                    player2PictureBox[0].Image = rotator.CounterClockWise(player2.List[0].Image);
                    firstMove(player2.List[0], player2PictureBox[0]);
                    player2PictureBox.RemoveAt(0);
                    player2.List.RemoveAt(0);
                    move = true;
                    break;
                }
            }
            if (!move)
            {
                if (!Yard(player2, 20))
                {
                    goto final;
                }
                PCMove();
            }
            if (Win(player2))
            {
                int sum = 0;
                for (int i = 0; i < player1.List.Count; i++)
                {
                    sum += player1.List[i].First + player1.List[i].Second;
                }
                StaticForScores.Score2 += sum;
                ScoreLabel.Text         = string.Format("{0}:{1}", StaticForScores.Score1, StaticForScores.Score2);
                MessageBox.Show("PC Won");
                NewRound();
                PCMove();
            }
            else if (Draw(player1, player2))
            {
                int sum1 = 0;
                for (int i = 0; i < player1.List.Count; i++)
                {
                    sum1 += player1.List[i].First + player1.List[i].Second;
                }
                StaticForScores.Score2 += sum1;
                int sum2 = 0;
                for (int i = 0; i < player2.List.Count; i++)
                {
                    sum2 += player2.List[i].First + player2.List[i].Second;
                }
                StaticForScores.Score1 += sum2;
                ScoreLabel.Text         = string.Format("{0}:{1}", StaticForScores.Score1 + (sum1 < sum2 ? sum2 - sum1 : 0), StaticForScores.Score2 + (sum1 > sum2 ? sum1 - sum2 : 0));
                MessageBox.Show("Draw");
                NewRound();
            }
final:
            PullTogether(player2, 20);
            (this as Form).Text = player1.List.Count + "." + player2.List.Count;
        }