olduğunda bir uyarıyı tetikler Benim okul projem için bir hafıza oyunu oluşturuyorum ve oyuncu oyunu kazandığında ve bir notu görüntülediğinde bir mesaj kutusu tetiklemede sorun yaşıyorum "Tüm kartlarla eşleştiniz! ". Çözüme sahip olan var mı? kodC# Tüm resimlerin bir değeri
Bir kısmı:
private void Card1_Click(object sender, EventArgs e)
{
Card1.Image = Properties.Resources.car1;
if(usedCard1 == null)
{
usedCard1 = Card1;
}
else if(usedCard1 != null && usedCard2 == null)
{
usedCard2 = Card1;
}
if(usedCard1 != null && usedCard2 != null)
{
if(usedCard1.Tag == usedCard2.Tag)
{
usedCard1 = null;
usedCard2 = null;
Card1.Enabled = false;
Dupcard1.Enabled = false;
points = Convert.ToInt32(ScoreCounter.Text);
points = points + 10;
ScoreCounter.Text = Convert.ToString(points);
}
else
{
points = Convert.ToInt32(ScoreCounter.Text);
points = points - 10;
ScoreCounter.Text = Convert.ToString(points);
timer4.Start();
}
}
}
private void Dupcard1_Click(object sender, EventArgs e)
{
Dupcard1.Image = Properties.Resources.car1;
if (usedCard1 == null)
{
usedCard1 = Dupcard1;
}
else if (usedCard1 != null && usedCard2 == null)
{
usedCard2 = Dupcard1;
}
if (usedCard1 != null && usedCard2 != null)
{
if (usedCard1.Tag == usedCard2.Tag)
{
usedCard1 = null;
usedCard2 = null;
Card1.Enabled = false;
Dupcard1.Enabled = false;
points = Convert.ToInt32(ScoreCounter.Text);
points = points + 10;
ScoreCounter.Text = Convert.ToString(points);
}
else
{
points = Convert.ToInt32(ScoreCounter.Text);
points = points - 10;
ScoreCounter.Text = Convert.ToString(points);
timer4.Start();
}
}
}
private void Win()
{
foreach(PictureBox picture in cardsHolder.Controls)
{
if(picture != null)
{
}
}
MessageBox.Show("You've matched all cards", "Congratulations");
Close();
}
PS: cardsHolder panelinin adıdır ve kazanın oyuncu oyunu kazanır iletiyi tetikleme yöntemidir.
Hangi kartların eşleştirildiğini nasıl takip edersiniz? – Jens
@Robin Oyunun kurallarını gönderebilir misiniz, böylece neye ihtiyacınız olduğunu daha iyi anlayabilir miyim? –