标签不改变文本的刽子手游戏c#



我在制作一款绞刑游戏,现在我想让它在2个玩家中运行He4e是每个按钮(字母)的代码当他点击它

if (label13.Text == "Player 1 Guess")
{

if (Fullword.Contains(button2.Text))
{
char[] temp = Underscore_Word.ToCharArray();
char[] found = Fullword.ToCharArray();
for (int i = 0; i < found.Length; i++)
{
if (found[i] == button2.Text.ElementAt(0))
{
temp[i] = button2.Text.ElementAt(0);
}
}
Underscore_Word = new string(temp);
PrintLabel();

}
else
{
faux++;
}
if (faux < 7)
{
pictureBox1.Image = images[faux];
}
else
{
label1.Text = "you lose !!! ";
User.score--;
label7.Text = "Score of " + Methods.displayName + ":  " + User.score.ToString();
label2.Visible = true;
label2.Text = "The word was :" + """ + Fullword + "" ";
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = "lose.wav";
player.Play();
}
if (Underscore_Word.Equals(Fullword))
{
label1.Text = "You Win!!";
User.score++;
label7.Text = "Score of " + Methods.displayName + ":  " + User.score.ToString();
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = "appllaud.wav";
player.Play();
}
label13.Text = "Player 2 Guess";
else
{
if (Fullword.Contains(button2.Text))
{
char[] temp = Underscore_Word.ToCharArray();
char[] found = Fullword.ToCharArray();
for (int i = 0; i < found.Length; i++)
{
if (found[i] == button2.Text.ElementAt(0))
{
temp[i] = button2.Text.ElementAt(0);
}
}
Underscore_Word = new string(temp);
PrintLabel();

}
else
{
faux_player2++;
}
if (faux_player2 < 7)
{
pictureBox2.Image = images[faux_player2]; 
}
else
{
label1.Text = "you lose !!! ";
User.score--;
label14.Text = "Score of " + Methods.displayName_playertwo + ":  " + User.score_Player2.ToString();
label2.Visible = true;
label2.Text = "The word was :" + """ + Fullword + "" ";
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = "lose.wav";
player.Play();
}
if (Underscore_Word.Equals(Fullword))
{
label1.Text = "You Win!!";
User.score_Player2++;
label14.Text = "Score of " + Methods.displayName_playertwo + ":  " + User.score_Player2.ToString(); ;
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = "appllaud.wav";
player.Play();
}

label13.Text = "Player 1 Guess";
}

我的标签有问题,它的停留播放器,我猜它的交替,当玩家得到一个错误的猜测,请帮助

你把}放在label13.Text = "Player 2 Guess";之后,else之前

if (label13.Text == "Player 1 Guess")
{
// code ....
}
else
{
// code ....
}

我也会建议你试着写更干净的代码,尽量不要重复你自己。

最新更新