private void pictureBox3_Click(object sender, EventArgs e) { limite = 4; turno = 1; RightArrow.Hide(); LeftArrow.Show(); Undo.Show(); for (int i = 1; i < 7; i++) { Reset(1, i); Reset(2, i); } Columna1[0].Location = new System.Drawing.Point(70, 95); Columna2[0].Location = new System.Drawing.Point(170, 95); Columna1[4].Text = Columna1[6].Text = r.Next(1, limite).ToString(); Columna1[4].BackColor = Columna1[6].BackColor = Colores[int.Parse(Columna1[4].Text) % 10]; int ran = r.Next(1, limite); while (ran == int.Parse(Columna1[4].Text)) { ran = r.Next(1, limite); } Columna1[5].Text = ran.ToString(); Columna1[5].BackColor = Colores[int.Parse(Columna1[5].Text) % 10]; Columna2[4].Text = Columna2[6].Text = r.Next(1, limite).ToString(); Columna2[4].BackColor = Columna2[6].BackColor = Colores[int.Parse(Columna2[4].Text) % 10]; while (ran == int.Parse(Columna2[4].Text)) { ran = r.Next(1, limite); } Columna2[5].Text = ran.ToString(); Columna2[5].BackColor = Colores[int.Parse(Columna2[5].Text) % 10]; Columna1[0].Text = r.Next(1, limite).ToString(); Columna1[0].BackColor = Colores[int.Parse(Columna1[0].Text) % 10]; Columna2[0].Text = r.Next(1, limite).ToString(); Columna2[0].BackColor = Colores[int.Parse(Columna2[0].Text) % 10]; Next.Text = r.Next(1, limite).ToString(); Next.BackColor = Colores[int.Parse(Next.Text) % 10]; label1.Text = "0"; score = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 7; j++) { saved[i][j] = 0; } } Save(); gameOver = false; }
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(); }
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(); }
private void pictureBox1_Click(object sender, EventArgs e) { sp.PlayLooping(); limite = 4; pictureBox1.Hide(); pictureBox2.Show(); pictureBox3.Show(); pictureBox4.Hide(); pictureBox5.Hide(); LeftArrow.Show(); label1.Show(); label4.Show(); Next.Show(); RightArrow.Hide(); LeftArrow.Show(); Undo.Show(); label1.Text = "0"; turno = 1; score = 0; for (int i = 0; i < 7; i++) { Columna1[i] = new Label(); Columna1[i].Name = i.ToString(); Columna1[i].Size = new Size(60, 30); Columna1[i].BackColor = Color.FromArgb(230, 230, 230); Columna1[i].TextAlign = ContentAlignment.MiddleCenter; Columna1[i].Font = new Font("Microsoft Sans Serif", 16); Columna1[i].ForeColor = Color.White; Columna1[i].Location = new System.Drawing.Point(70, i * 35 + 120); Columna1[i].Click += Form1_Click; this.Controls.Add(Columna1[i]); } Columna1[0].Location = new System.Drawing.Point(70, 95); for (int i = 0; i < 7; i++) { Columna2[i] = new Label(); Columna2[i].Name = i.ToString(); Columna2[i].Size = new Size(60, 30); Columna2[i].BackColor = Color.FromArgb(230, 230, 230); Columna2[i].TextAlign = ContentAlignment.MiddleCenter; Columna2[i].Font = new Font("Microsoft Sans Serif", 16); Columna2[i].ForeColor = Color.White; Columna2[i].Location = new System.Drawing.Point(170, i * 35 + 120); Columna2[i].Click += Form2_Click; this.Controls.Add(Columna2[i]); } Columna2[0].Location = new System.Drawing.Point(170, 95); Columna1[1].BackColor = Columna2[1].BackColor = Color.FromArgb(255, 215, 215); Columna1[4].Text = Columna1[6].Text = r.Next(1, limite).ToString(); Columna1[4].BackColor = Columna1[6].BackColor = Colores[int.Parse(Columna1[4].Text) % 10]; int ran = r.Next(1, limite); while (ran == int.Parse(Columna1[4].Text)) { ran = r.Next(1, limite); } Columna1[5].Text = ran.ToString(); Columna1[5].BackColor = Colores[int.Parse(Columna1[5].Text) % 10]; Columna2[4].Text = Columna2[6].Text = r.Next(1, limite).ToString(); Columna2[4].BackColor = Columna2[6].BackColor = Colores[int.Parse(Columna2[4].Text) % 10]; while (ran == int.Parse(Columna2[4].Text)) { ran = r.Next(1, limite); } Columna2[5].Text = ran.ToString(); Columna2[5].BackColor = Colores[int.Parse(Columna2[5].Text) % 10]; Columna1[0].Text = r.Next(1, limite).ToString(); Columna1[0].BackColor = Colores[int.Parse(Columna1[0].Text) % 10]; Columna2[0].Text = r.Next(1, limite).ToString(); Columna2[0].BackColor = Colores[int.Parse(Columna2[0].Text) % 10]; Next.Text = r.Next(1, limite).ToString(); Next.BackColor = Colores[int.Parse(Next.Text) % 10]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 7; j++) { saved[i][j] = 0; } } Save(); gameOver = false; }
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; } }