コード例 #1
0
        private void OtomatikHareketEt()
        {
            int kuzey = (int)dGVLabirent[FareXCurrent, FareYCurrent - 1].Tag;
            int guney = (int)dGVLabirent[FareXCurrent, FareYCurrent + 1].Tag;
            int bati  = (int)dGVLabirent[FareXCurrent - 1, FareYCurrent].Tag;
            int dogu  = (int)dGVLabirent[FareXCurrent + 1, FareYCurrent].Tag;

            if (kuzey <= guney && kuzey <= bati && kuzey <= dogu && kuzey != 999)
            {
                if ((int)dGVLabirent[FareXCurrent, FareYCurrent - 1].Tag == peynir)
                {
                    HamleSayisi += 1;
                    dGVLabirent[FareXCurrent, FareYCurrent].Value   = null;
                    dGVLabirent[FareXCurrent, FareYCurrent].Value   = Image.FromFile("yol.jpeg");
                    dGVLabirent[FareXCurrent, --FareYCurrent].Value = Image.FromFile("fare.png");
                    BilgisayarBekletme.Stop();
                    BilgisayarBekletme.Enabled = false;
                    MessageBox.Show("Peynir " + HamleSayisi + " hamlede bulundu."); AnaSayfa anaSayfa = new AnaSayfa();
                    anaSayfa.Show();
                    this.Hide();
                }
                else
                {
                    HamleSayisi += 1;
                    dGVLabirent[FareXCurrent, FareYCurrent].Value   = null;
                    dGVLabirent[FareXCurrent, FareYCurrent].Value   = Image.FromFile("yol.jpeg");
                    dGVLabirent[FareXCurrent, --FareYCurrent].Value = Image.FromFile("fare.png");
                    dGVLabirent[FareXCurrent, FareYCurrent].Tag     = (int)dGVLabirent[FareXCurrent, FareYCurrent].Tag + 1;
                }
            }
            else if (guney <= kuzey && guney <= bati && guney <= dogu && guney != 999)
            {
                if ((int)dGVLabirent[FareXCurrent, FareYCurrent + 1].Tag == peynir)
                {
                    HamleSayisi += 1;
                    dGVLabirent[FareXCurrent, FareYCurrent].Value   = null;
                    dGVLabirent[FareXCurrent, FareYCurrent].Value   = Image.FromFile("yol.jpeg");
                    dGVLabirent[FareXCurrent, ++FareYCurrent].Value = Image.FromFile("fare.png");
                    BilgisayarBekletme.Stop();
                    BilgisayarBekletme.Enabled = false;
                    MessageBox.Show("Peynir " + HamleSayisi + " hamlede bulundu."); AnaSayfa anaSayfa = new AnaSayfa();
                    anaSayfa.Show();
                    this.Hide();
                }
                else
                {
                    HamleSayisi += 1;
                    dGVLabirent[FareXCurrent, FareYCurrent].Value   = null;
                    dGVLabirent[FareXCurrent, FareYCurrent].Value   = Image.FromFile("yol.jpeg");
                    dGVLabirent[FareXCurrent, ++FareYCurrent].Value = Image.FromFile("fare.png");
                    dGVLabirent[FareXCurrent, FareYCurrent].Tag     = (int)dGVLabirent[FareXCurrent, FareYCurrent].Tag + 1;
                }
            }
            else if (bati <= guney && bati <= kuzey && bati <= dogu && bati != 999)
            {
                if ((int)dGVLabirent[FareXCurrent - 1, FareYCurrent].Tag == peynir)
                {
                    HamleSayisi += 1;
                    dGVLabirent[FareXCurrent, FareYCurrent].Value   = null;
                    dGVLabirent[FareXCurrent, FareYCurrent].Value   = Image.FromFile("yol.jpeg");
                    dGVLabirent[--FareXCurrent, FareYCurrent].Value = Image.FromFile("fare.png");
                    BilgisayarBekletme.Stop();
                    BilgisayarBekletme.Enabled = false;
                    MessageBox.Show("Peynir " + HamleSayisi + " hamlede bulundu."); AnaSayfa anaSayfa = new AnaSayfa();
                    anaSayfa.Show();
                    this.Hide();
                }
                else
                {
                    HamleSayisi += 1;
                    dGVLabirent[FareXCurrent, FareYCurrent].Value   = null;
                    dGVLabirent[FareXCurrent, FareYCurrent].Value   = Image.FromFile("yol.jpeg");
                    dGVLabirent[--FareXCurrent, FareYCurrent].Value = Image.FromFile("fare.png");
                    dGVLabirent[FareXCurrent, FareYCurrent].Tag     = (int)dGVLabirent[FareXCurrent, FareYCurrent].Tag + 1;
                }
            }
            else if (dogu <= guney && dogu <= bati && dogu <= kuzey && dogu != 999)
            {
                if ((int)dGVLabirent[FareXCurrent + 1, FareYCurrent].Tag == peynir)
                {
                    HamleSayisi += 1;
                    dGVLabirent[FareXCurrent, FareYCurrent].Value   = null;
                    dGVLabirent[FareXCurrent, FareYCurrent].Value   = Image.FromFile("yol.jpeg");
                    dGVLabirent[++FareXCurrent, FareYCurrent].Value = Image.FromFile("fare.png");
                    BilgisayarBekletme.Stop();
                    BilgisayarBekletme.Enabled = false;
                    MessageBox.Show("Peynir " + HamleSayisi + " hamlede bulundu."); AnaSayfa anaSayfa = new AnaSayfa();
                    anaSayfa.Show();
                    this.Hide();
                }
                else
                {
                    HamleSayisi += 1;
                    dGVLabirent[FareXCurrent, FareYCurrent].Value   = null;
                    dGVLabirent[FareXCurrent, FareYCurrent].Value   = Image.FromFile("yol.jpeg");
                    dGVLabirent[++FareXCurrent, FareYCurrent].Value = Image.FromFile("fare.png");
                    dGVLabirent[FareXCurrent, FareYCurrent].Tag     = (int)dGVLabirent[FareXCurrent, FareYCurrent].Tag + 1;
                }
            }
        }
コード例 #2
0
 private void HareketEt(object sender, KeyEventArgs e)
 {
     if (this.OyunModu == 1)
     {
         if (e.KeyData == Keys.Right && (int)dGVLabirent[FareXCurrent + 1, FareYCurrent].Tag != duvar)
         {
             if (e.KeyData == Keys.Right && (int)dGVLabirent[FareXCurrent + 1, FareYCurrent].Tag == peynir)
             {
                 HamleSayisi += 1;
                 dGVLabirent[FareXCurrent, FareYCurrent].Value   = null;
                 dGVLabirent[FareXCurrent, FareYCurrent].Value   = Image.FromFile("yol.jpeg");
                 dGVLabirent[++FareXCurrent, FareYCurrent].Value = Image.FromFile("fare.png");
                 MessageBox.Show("Peynir " + HamleSayisi + " hamlede bulundu.");
                 AnaSayfa anaSayfa = new AnaSayfa();
                 anaSayfa.Show();
                 this.Hide();
             }
             else
             {
                 HamleSayisi += 1;
                 dGVLabirent[FareXCurrent, FareYCurrent].Value   = null;
                 dGVLabirent[FareXCurrent, FareYCurrent].Value   = Image.FromFile("yol.jpeg");
                 dGVLabirent[++FareXCurrent, FareYCurrent].Value = Image.FromFile("fare.png");
             }
         }
         if (e.KeyData == Keys.Left && (int)dGVLabirent[FareXCurrent - 1, FareYCurrent].Tag != duvar)
         {
             if (e.KeyData == Keys.Left && (int)dGVLabirent[FareXCurrent - 1, FareYCurrent].Tag == peynir)
             {
                 HamleSayisi += 1;
                 dGVLabirent[FareXCurrent, FareYCurrent].Value   = null;
                 dGVLabirent[FareXCurrent, FareYCurrent].Value   = Image.FromFile("yol.jpeg");
                 dGVLabirent[--FareXCurrent, FareYCurrent].Value = Image.FromFile("fare.png");
                 MessageBox.Show("Peynir " + HamleSayisi + " hamlede bulundu."); AnaSayfa anaSayfa = new AnaSayfa();
                 anaSayfa.Show();
                 this.Hide();
             }
             else
             {
                 HamleSayisi += 1;
                 dGVLabirent[FareXCurrent, FareYCurrent].Value   = null;
                 dGVLabirent[FareXCurrent, FareYCurrent].Value   = Image.FromFile("yol.jpeg");
                 dGVLabirent[--FareXCurrent, FareYCurrent].Value = Image.FromFile("fare.png");
             }
         }
         if (e.KeyData == Keys.Up && (int)dGVLabirent[FareXCurrent, FareYCurrent - 1].Tag != duvar)
         {
             if (e.KeyData == Keys.Up && (int)dGVLabirent[FareXCurrent, FareYCurrent - 1].Tag == peynir)
             {
                 HamleSayisi += 1;
                 dGVLabirent[FareXCurrent, FareYCurrent].Value   = null;
                 dGVLabirent[FareXCurrent, FareYCurrent].Value   = Image.FromFile("yol.jpeg");
                 dGVLabirent[FareXCurrent, --FareYCurrent].Value = Image.FromFile("fare.png");
                 MessageBox.Show("Peynir " + HamleSayisi + " hamlede bulundu."); AnaSayfa anaSayfa = new AnaSayfa();
                 anaSayfa.Show();
                 this.Hide();
             }
             else
             {
                 HamleSayisi += 1;
                 dGVLabirent[FareXCurrent, FareYCurrent].Value   = null;
                 dGVLabirent[FareXCurrent, FareYCurrent].Value   = Image.FromFile("yol.jpeg");
                 dGVLabirent[FareXCurrent, --FareYCurrent].Value = Image.FromFile("fare.png");
             }
         }
         if (e.KeyData == Keys.Down && (int)dGVLabirent[FareXCurrent, FareYCurrent + 1].Tag != duvar)
         {
             if (e.KeyData == Keys.Down && (int)dGVLabirent[FareXCurrent, FareYCurrent + 1].Tag == peynir)
             {
                 HamleSayisi += 1;
                 dGVLabirent[FareXCurrent, FareYCurrent].Value   = null;
                 dGVLabirent[FareXCurrent, FareYCurrent].Value   = Image.FromFile("yol.jpeg");
                 dGVLabirent[FareXCurrent, ++FareYCurrent].Value = Image.FromFile("fare.png");
                 MessageBox.Show("Peynir " + HamleSayisi + " hamlede bulundu."); AnaSayfa anaSayfa = new AnaSayfa();
                 anaSayfa.Show();
                 this.Hide();
             }
             else
             {
                 HamleSayisi += 1;
                 dGVLabirent[FareXCurrent, FareYCurrent].Value   = null;
                 dGVLabirent[FareXCurrent, FareYCurrent].Value   = Image.FromFile("yol.jpeg");
                 dGVLabirent[FareXCurrent, ++FareYCurrent].Value = Image.FromFile("fare.png");
             }
         }
     }
 }