winforms
私はREMEMBER meゲームのロジックを使ったアプリケーションを持っています。私が欲しいのは、リセットボタンをクリックするか、ゲームを実行するたびに、ボタンの位置が異なる(ゴロゴロ鳴る)ので、ゲームが面白くなるということです:)
これはこれまでの私のコードです
public partial class Form1 : Form
{
int b1 = 1, b2 = 2, b3 = 3,b4 = 4,b5 = 5,b6 = 6;
public Form1()
{
InitializeComponent();
}
private void Wrong_Tick(object sender, EventArgs e)
{
progressBar1.Increment(10);
if (progressBar1.Value == 100)
{
Wrong.Stop();
button1.Text = "";
button2.Text = "";
button3.Text = "";
button4.Text = "";
button5.Text = "";
button6.Text = "";
b1 = 1;
b2 = 2;
b3 = 3;
b4 = 4;
b5 = 5;
b6 = 6;
progressBar1.Value = 0;
}
}
private void Tb1b2_Tick(object sender, EventArgs e)
{
progressBar1.Increment(10);
if (progressBar1.Value == 100)
{
Tb1b2.Stop();
button1.Visible = false;
button2.Visible = false;
progressBar1.Value = 0;
}
}
private void Tb3b4_Tick(object sender, EventArgs e)
{
progressBar1.Increment(10);
if (progressBar1.Value == 100)
{
Tb3b4.Stop();
button3.Visible = false;
button4.Visible = false;
progressBar1.Value = 0;
}
}
private void Tb5b6_Tick(object sender, EventArgs e)
{
progressBar1.Increment(10);
if (progressBar1.Value == 100)
{
Tb5b6.Stop();
button5.Visible = false;
button6.Visible = false;
progressBar1.Value = 0;
}
}
private void button1_Click(object sender, EventArgs e)
{
if(b1 == 1)
{
b1 = 0;
button1.Text = "kevin";
if (b1 == b2)
{
Tb1b2.Start();
}
else if (b1 == b3)
{
Wrong.Start();
}
else if (b1 == b4)
{
Wrong.Start();
}
else if (b1 == b5)
{
Wrong.Start();
}
else if (b1 == b6)
{
Wrong.Start();
}
}
else if (b1 == 0)
{
b1 = 1;
button1.Text = "";
}
}
private void button2_Click(object sender, EventArgs e)
{
if (b2 == 2)
{
b2 = 0;
button2.Text = "kevin";
if (b2 == b1)
{
Tb1b2.Start();
}
else if (b2 == b3)
{
Wrong.Start();
}
else if (b2 == b4)
{
Wrong.Start();
}
else if (b2 == b5)
{
Wrong.Start();
}
else if (b2 == b6)
{
Wrong.Start();
}
}
else if (b1 == 0)
{
b2 = 2;
button2.Text = "";
}
}
private void button3_Click(object sender, EventArgs e)
{
if (b3 == 3)
{
b3 = 0;
button3.Text = "kath";
if (b3 == b4)
{
Tb3b4.Start();
}
else if (b3 == b1)
{
Wrong.Start();
}
else if (b3 == b2)
{
Wrong.Start();
}
else if (b3 == b5)
{
Wrong.Start();
}
else if (b3 == b6)
{
Wrong.Start();
}
}
else if (b3 == 0)
{
b3 = 3;
button1.Text = "";
}
}
private void button4_Click(object sender, EventArgs e)
{
if (b4 == 4)
{
b4 = 0;
button4.Text = "kath";
if (b4 == b3)
{
Tb3b4.Start();
}
else if (b4 == b1)
{
Wrong.Start();
}
else if (b4 == b2)
{
Wrong.Start();
}
else if (b4 == b5)
{
Wrong.Start();
}
else if (b4 == b6)
{
Wrong.Start();
}
}
else if (b4 == 0)
{
b4 = 3;
button4.Text = "";
}
}
private void button5_Click(object sender, EventArgs e)
{
if (b5 == 5)
{
b5 = 0;
button5.Text = "eka";
if (b5 == b6)
{
Tb5b6.Start();
}
else if (b5 == b1)
{
Wrong.Start();
}
else if (b5 == b2)
{
Wrong.Start();
}
else if (b5 == b3)
{
Wrong.Start();
}
else if (b5 == b4)
{
Wrong.Start();
}
}
else if (b5 == 0)
{
b5 = 5;
button5.Text = "";
}
}
private void button6_Click(object sender, EventArgs e)
{
if (b6 == 6)
{
b6 = 0;
button6.Text = "eka";
if (b6 == b5)
{
Tb5b6.Start();
}
else if (b6 == b1)
{
Wrong.Start();
}
else if (b6 == b2)
{
Wrong.Start();
}
else if (b6 == b3)
{
Wrong.Start();
}
else if (b6 == b4)
{
Wrong.Start();
}
}
else if (b6 == 0)
{
b6 = 6;
button6.Text = "";
}
}
private void Reset_Click(object sender, EventArgs e)
{
b1 = 1;
b2 = 2;
b3 = 3;
b4 = 4;
b5 = 5 ;
b6 = 6;
button1.Visible = true;
button2.Visible = true;
button3.Visible = true;
button4.Visible = true;
button5.Visible = true;
button6.Visible = true;
button1.Text = "";
button2.Text = "";
button3.Text = "";
button4.Text = "";
button5.Text = "";
button6.Text = "";
}
}