Exemple #1
0
 private void Restart()
 {
     pictureBox2.Hide();
     pictureBox3.Hide();
     pictureBox4.Show();
     //pictureBox5.Show();
     Undo.Hide();
     label1.Hide();
     label4.Hide();
     Next.Hide();
     RightArrow.Hide();
     LeftArrow.Hide();
     for (int i = 0; i < 7; i++)
     {
         this.Controls.Remove(Columna1[i]);
         this.Controls.Remove(Columna2[i]);
     }
     pictureBox1.Show();
 }
Exemple #2
0
        private void Undo_Click(object sender, EventArgs e)
        {
            Undo.Hide();
            for (int i = 0; i < 7; i++)
            {
                if (saved[1][i] == 0)
                {
                    Reset(1, i);
                }
                else
                {
                    Columna1[i].Text      = saved[1][i].ToString();
                    Columna1[i].BackColor = Colores[saved[1][i] % 10];
                }

                if (saved[2][i] == 0)
                {
                    Reset(2, i);
                }
                else
                {
                    Columna2[i].Text      = saved[2][i].ToString();
                    Columna2[i].BackColor = Colores[saved[2][i] % 10];
                }


                Next.Text      = saved[0][0].ToString();
                Next.BackColor = Colores[saved[0][0] % 10];
                turno          = saved[0][1];
                score          = saved[0][2];
            }
            if (turno == 1)
            {
                RightArrow.Hide();
                LeftArrow.Show();
            }
            else
            {
                RightArrow.Show();
                LeftArrow.Hide();
            }
            label1.Text = score.ToString();
        }
Exemple #3
0
        private void GameUpdate()
        {
            Recorrer();
            for (int i = 1; i < 6; i++)
            {
                if (Columna1[i].Text != "" && Columna1[i].Text == Columna1[i + 1].Text)
                {
                    Columna1[i + 1].Text      = (int.Parse(Columna1[i + 1].Text) + 1).ToString();
                    Columna1[i + 1].BackColor = Colores[int.Parse(Columna1[i + 1].Text) % 10];
                    score      += (int)Math.Pow(2, int.Parse(Columna1[i + 1].Text));
                    label1.Text = score.ToString();
                    Reset(1, i);
                    Recorrer();
                    if (Columna1[i + 1].Text != "" && int.Parse(Columna1[i + 1].Text) > limite)
                    {
                        limite = int.Parse(Columna1[i + 1].Text);
                    }
                }
            }
            for (int i = 1; i < 6; i++)
            {
                if (Columna2[i].Text != "" && Columna2[i].Text == Columna2[i + 1].Text)
                {
                    Columna2[i + 1].Text      = (int.Parse(Columna2[i + 1].Text) + 1).ToString();
                    Columna2[i + 1].BackColor = Colores[int.Parse(Columna2[i + 1].Text) % 10];
                    score      += (int)Math.Pow(2, int.Parse(Columna2[i + 1].Text));
                    label1.Text = score.ToString();
                    Reset(2, i);
                    Recorrer();
                    if (Columna2[i + 1].Text != "" && int.Parse(Columna2[i + 1].Text) > limite)
                    {
                        limite = int.Parse(Columna2[i + 1].Text);
                    }
                }
            }
            Recorrer();
            if (turno == 1)
            {
                Columna1[1].Text      = Columna1[0].Text;
                Columna1[1].BackColor = Columna1[0].BackColor;
                Columna1[0].Text      = Next.Text;
                Columna1[0].BackColor = Next.BackColor;
                Next.Text             = r.Next(1, limite).ToString();
                Next.BackColor        = Colores[int.Parse(Next.Text) % 10];
                turno = 3;
                GameUpdate();
            }
            else if (turno == 2)
            {
                Columna2[1].Text      = Columna2[0].Text;
                Columna2[1].BackColor = Columna2[0].BackColor;
                Columna2[0].Text      = Next.Text;
                Columna2[0].BackColor = Next.BackColor;
                Next.Text             = r.Next(1, limite).ToString();
                Next.BackColor        = Colores[int.Parse(Next.Text) % 10];
                turno = 4;
                GameUpdate();
            }
            else if (turno == 3)
            {
                turno = 2;
                RightArrow.Show();
                LeftArrow.Hide();
            }
            else if (turno == 4)
            {
                turno = 1;
                RightArrow.Hide();
                LeftArrow.Show();
            }

            if (Columna1[1].Text != "" || Columna2[1].Text != "")
            {
                if (score > int.Parse(label3.Text))
                {
                    label3.Text = score.ToString();
                }
                if (!gameOver)
                {
                    MessageBox.Show("Juego Terminado!");
                    Restart();
                }
                gameOver = true;
            }
        }