using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApp7 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } string pic_u, pic_pc; private void pictureBox5_Click(object sender, EventArgs e) { timer1.Start(); timer2.Start(); PictureBox pic = (PictureBox)sender; pic_u = pic.Name; } private void winner(string p_u, string p_pc) { if (p_u == "Камень" && p_pc == "Ножницы") { label4.Text = (int.Parse(label4.Text)+1).ToString(); MessageBox.Show("Победа за тобой"); pictureBox1.Image = Properties.Resources.Пусто; } if (p_u == "Ножницы" && p_pc == "Камень") { label2.Text = (int.Parse(label2.Text) + 1).ToString(); MessageBox.Show("Победа за компьютером"); pictureBox1.Image = Properties.Resources.Пусто; } if (p_u == "Камень" && p_pc == "Камень") { MessageBox.Show("Ничья"); pictureBox1.Image = Properties.Resources.Пусто; } if (p_u == "Ножницы" && p_pc == "Ножницы") { MessageBox.Show("Ничья"); pictureBox1.Image = Properties.Resources.Пусто; } if (p_u == "Камень" && p_pc == "Бумага") { label2.Text = (int.Parse(label2.Text) + 1).ToString(); MessageBox.Show("Победа за компьютером"); pictureBox1.Image = Properties.Resources.Пусто; } if (p_u == "Бумага" && p_pc == "Камень") { label4.Text = (int.Parse(label4.Text) + 1).ToString(); MessageBox.Show("Победа за тобой"); pictureBox1.Image = Properties.Resources.Пусто; } if (p_u == "Бумага" && p_pc == "Бумага") { MessageBox.Show("Ничья"); pictureBox1.Image = Properties.Resources.Пусто; } if (p_u == "Бумага" && p_pc == "Ножницы") { label2.Text = (int.Parse(label2.Text) + 1).ToString(); MessageBox.Show("Победа за компьютером"); pictureBox1.Image = Properties.Resources.Пусто; } if (p_u == "Ножницы" && p_pc == "Бумага") { label4.Text = (int.Parse(label4.Text) + 1).ToString(); MessageBox.Show("Победа за тобой"); pictureBox1.Image = Properties.Resources.Пусто; } } Random rnd = new Random(); private void timer1_Tick(object sender, EventArgs e) { int turn = rnd.Next(0, 3); if (turn == 0) { pictureBox1.Image = Properties.Resources.Бумага; pic_pc = "Бумага"; } if (turn == 1) { pictureBox1.Image = Properties.Resources.Ножницы; pic_pc = "Ножницы"; } if (turn == 2) { pictureBox1.Image = Properties.Resources.Камень; pic_pc = "Камень"; } } private void button1_Click(object sender, EventArgs e) { label2.ToString(); label4.ToString(); pictureBox1.Image = Properties.Resources.Пусто; } private void timer2_Tick(object sender, EventArgs e) { timer1.Stop(); timer2.Stop(); winner(pic_u, pic_pc); } } }