コード例 #1
0
 public KutuTablosu(Size buyukluk)
 {
     kutular       = new List <Kutu>();
     this.buyukluk = buyukluk;
     for (int x = 0; x < buyukluk.Width; x = x + 40)
     {
         for (int y = 0; y < buyukluk.Height; y = y + 40)
         {
             Kutu k = new Kutu(new Point(x, y));
             KutuEkle(k);
         }
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: omersavas/Yaz-l-mYap-m-Oyun
        void btn_Click(object sender, EventArgs e)
        {
            Button btn = (sender as Button);
            Kutu   k   = kutuTablo.kutu_al_loc(btn.Location);

            foreach (Kutu item in kutuTablo.kutular)
            {
                if (item.tiklandimi == false)
                {
                    bosKutuSayi++;
                }
            }
            if (bosKutuSayi == 0)
            {
                MessageBox.Show("Tebrikler Kazandınız");
            }
            else
            {
                if (k.tiklandimi != true && btn.BackColor == Color.Aqua)
                {
                    foreach (Button item in butonlar)
                    {
                        Kutu tempK = kutuTablo.kutu_al_loc(item.Location);
                        if (tempK.tiklandimi == false)
                        {
                            item.BackColor = Color.White;
                        }
                    }

                    btn.Text = tiklamaSayi.ToString();
                    tiklamaSayi++;
                    btn.BackColor = Color.Tomato;
                    k.tiklandimi  = true;

                    foreach (Button tempBtn in butonlar)
                    {
                        if (k.konum_al.X - 80 == tempBtn.Location.X && k.konum_al.Y + 40 == tempBtn.Location.Y)
                        {
                            if (tempBtn.BackColor != Color.Tomato)
                            {
                                tempBtn.BackColor = Color.Aqua;
                            }
                        }
                        if (k.konum_al.X - 40 == tempBtn.Location.X && k.konum_al.Y + 80 == tempBtn.Location.Y)
                        {
                            if (tempBtn.BackColor != Color.Tomato)
                            {
                                tempBtn.BackColor = Color.Aqua;
                            }
                        }
                        if (k.konum_al.X + 40 == tempBtn.Location.X && k.konum_al.Y + 80 == tempBtn.Location.Y)
                        {
                            if (tempBtn.BackColor != Color.Tomato)
                            {
                                tempBtn.BackColor = Color.Aqua;
                            }
                        }
                        if (k.konum_al.X + 80 == tempBtn.Location.X && k.konum_al.Y + 40 == tempBtn.Location.Y)
                        {
                            if (tempBtn.BackColor != Color.Tomato)
                            {
                                tempBtn.BackColor = Color.Aqua;
                            }
                        }
                        if (k.konum_al.X + 80 == tempBtn.Location.X && k.konum_al.Y - 40 == tempBtn.Location.Y)
                        {
                            if (tempBtn.BackColor != Color.Tomato)
                            {
                                tempBtn.BackColor = Color.Aqua;
                            }
                        }
                        if (k.konum_al.X + 40 == tempBtn.Location.X && k.konum_al.Y - 80 == tempBtn.Location.Y)
                        {
                            if (tempBtn.BackColor != Color.Tomato)
                            {
                                tempBtn.BackColor = Color.Aqua;
                            }
                        }
                        if (k.konum_al.X - 40 == tempBtn.Location.X && k.konum_al.Y - 80 == tempBtn.Location.Y)
                        {
                            if (tempBtn.BackColor != Color.Tomato)
                            {
                                tempBtn.BackColor = Color.Aqua;
                            }
                        }
                        if (k.konum_al.X - 80 == tempBtn.Location.X && k.konum_al.Y - 40 == tempBtn.Location.Y)
                        {
                            if (tempBtn.BackColor != Color.Tomato)
                            {
                                tempBtn.BackColor = Color.Aqua;
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Sadece Mavi Olanlara ve Daha Önce Tıklamadığınız Karelere Tıklanabilir");
                }

                foreach (Button item in butonlar)
                {
                    if (item.BackColor == Color.Aqua)
                    {
                        tiklanaBilirKutuSayisi++;
                    }
                }
                label1.Text = "Oynanabilecek Hamle :" + tiklanaBilirKutuSayisi.ToString();


                if (bosKutuSayi != 0 && tiklanaBilirKutuSayisi == 0)
                {
                    MessageBox.Show("Hamleniz Kalmadı Oyunu Kaybettiniz");
                }
                tiklanaBilirKutuSayisi = 0;
            }
        }
コード例 #3
0
 public void KutuEkle(Kutu o)
 {
     kutular.Add(o);
 }