Exemple #1
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();
        }
Exemple #2
0
        public void PictureBox_Click(object sender, EventArgs e)
        {
            Domino     domino;
            PictureBox pbox;

            if (sender is PictureBox)
            {
                pbox   = sender as PictureBox;
                domino = new Domino(pbox.Image);
            }
            else
            {
                domino     = sender as Domino;
                pbox       = new PictureBox();
                pbox.Image = domino.Image;
                Controls.Add(pbox);
            }
            if (domino.Contains(Right) || domino.Contains(Left) || Right == 7)
            {
                Blocked = true;
                table.Add(pbox);
                player1PictureBox.Remove(pbox);
                player1.List.Remove(domino);
                pbox.Click -= PictureBox_Click;
                if (Right == 7)
                {
                    firstMove(domino, pbox);
                }
                else if (domino.Contains(Right))
                {
                    rightMove(domino, pbox);
                }
                else if (domino.Contains(Left))
                {
                    leftMove(domino, pbox);
                }
                if (type != GameType.Local)
                {
                    DominoSender Sender = new DominoSender(DominoSendingState.Move, domino);
                    TcpSender.Send(Sender.Bytes());
                }
                else
                {
                    PCMove();
                }
            }
            PullTogether(player1, 486);
            (this as Form).Text = player1.List.Count + "." + player2.List.Count;
            if (Win(player1))
            {
                int sum = 0;
                for (int i = 0; i < player2.List.Count; i++)
                {
                    sum += player2.List[i].First + player2.List[i].Second;
                }
                StaticForScores.Score1 += sum;
                ScoreLabel.Text         = string.Format("{0}:{1}", StaticForScores.Score1, StaticForScores.Score2);
                if (StaticForScores.Score1 > 101)
                {
                    MessageBox.Show("Player Won the Game");
                    Application.Exit();
                }
                else
                {
                    MessageBox.Show("Player Won");
                }
                NewRound();
            }
            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 ? sum1 - sum2 : 0, StaticForScores.Score2 + sum1 < sum2 ? sum2 - sum1 : 0);
                MessageBox.Show("Draw");
                NewRound();
            }
        }
Exemple #3
0
 public void Move(Domino domino)
 {
     List.Remove(domino);
 }