Exemplo n.º 1
0
        public void dosyadanOku()
        {
            string dosya_yolu = @harita;

            FileStream fs = new FileStream(dosya_yolu, FileMode.Open, FileAccess.Read);

            StreamReader sw = new StreamReader(fs);

            string yazi = sw.ReadLine();

            while (yazi != null)
            {
                int    posX   = Convert.ToInt32(yazi.Split(',')[0]);
                int    posY   = Convert.ToInt32(yazi.Split(',')[1]);
                int    boyutX = Convert.ToInt32(yazi.Split(',')[2]);
                int    boyutY = Convert.ToInt32(yazi.Split(',')[3]);
                string tag    = yazi.Split(',')[4];


                kutu a = new kutu();
                a.Location = new Point(posX, posY);
                a.Size     = new Size(boyutX, boyutY);
                a.Tag      = tag;
                panel2.Controls.Add(a);


                yazi = sw.ReadLine();
            }

            sw.Close();
            fs.Close();
        }
Exemplo n.º 2
0
        public void baslangic()
        {
            //karakter.Parent = pictureBox1;
            //oyuncu.bombaEkle();
            //MessageBox.Show(oyuncu.bombaSayisi.ToString());
            //foreach (Control item in panel2.Controls)
            //{
            //    if (item is kutu)
            //        panel2.Controls.Remove(item);
            //}
            tumKutular.Clear();
            panel2.Controls.Clear();
            LevelAtla();
            dosyadanOku();
            //IIIIIIIIIIIIIIIIIII
            karakter.BackgroundImage       = karakterResim;
            karakter.BackgroundImageLayout = ImageLayout.Stretch;
            panel2.Controls.Add(karakter);
            MessageBox.Show("Level " + level.ToString());
            karakter.Location = new Point(0, 0);


            foreach (Control item in panel2.Controls)
            {
                if (item is kutu)
                {
                    // item.Parent = pictureBox1;
                    kutu kutum = (kutu)item;
                    //if (item.Tag.ToString()!="bos")
                    //    if (r.Next(0, 5)==1 ) {
                    //    item.Tag = "mayin";

                    //}

                    if (item.Tag.ToString() == "mayin" ||
                        item.Tag.ToString() == "kutu" ||
                        item.Tag.ToString() == "bomba")
                    {
                        kutum.BackgroundImage = mayintarlasi.Properties.Resources.varil;
                        kutum.BackColor       = Color.Transparent;
                        kutum.BringToFront();
                        item.Click += İtem_Click;
                    }
                    else if (item.Tag.ToString() == "iskele")
                    {
                        kutum.BackgroundImage = null;
                        kutum.BackColor       = Color.LightGreen;
                        kutum.BringToFront();
                    }

                    tumKutular.Add(kutum);

                    //MessageBox.Show(item.Tag.ToString());
                    //Image.FromFile(@"gorseller\kutu.png");
                }   // item.tiklandiMi = true;
            }
        }
 public void bosSayfa()
 {
     for (int i = 0; i < 20; i++)
     {
         for (int j = 0; j < 8; j++)
         {
             kutu a = new kutu();
             a.Size      = new Size(40, 40);
             a.Location  = new Point(i * 40, j * 40);
             a.BackColor = Color.DarkSlateGray;
             a.Tag       = "bos";
             panel1.Controls.Add(a);
             a.Click += A_Click;
         }
     }
 }
        private void A_Click(object sender, EventArgs e)
        {
            kutu a = (kutu)sender;

            if (rbBos.Checked)
            {
                a.Tag       = "kutu";
                a.BackColor = Color.Green;
            }
            if (rbBomba.Checked)
            {
                a.Tag       = "bomba";
                a.BackColor = Color.Blue;
            }
            if (rbMayin.Checked)
            {
                a.Tag       = "mayin";
                a.BackColor = Color.Red;
            }
            if (rbIskele.Checked)
            {
                bool var = false;
                foreach (Control item in panel1.Controls)
                {
                    if (item is kutu)
                    {
                        if (item.Tag.ToString() == "iskele")
                        {
                            var = true;
                            break;
                        }
                    }
                }
                if (var)
                {
                    MessageBox.Show("sadece 1 iskele yerleştirebilirsinişz");
                }
                else
                {
                    a.Tag       = "iskele";
                    a.BackColor = Color.LightSeaGreen;
                }
            }
            // MessageBox.Show(a.Tag.ToString());

            // throw new NotImplementedException();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            // string harita;
            panel1.Controls.Clear();

            harita = listBox1.Text;
            string dosya_yolu = @"haritalar/" + harita;
            //Okuma işlem yapacağımız dosyanın yolunu belirtiyoruz.
            FileStream fs = new FileStream(dosya_yolu, FileMode.Open, FileAccess.Read);
            //Bir file stream nesnesi oluşturuyoruz. 1.parametre dosya yolunu,
            //2.parametre dosyanın açılacağını,
            //3.parametre dosyaya erişimin veri okumak için olacağını gösterir.
            StreamReader sw = new StreamReader(fs);
            //Okuma işlemi için bir StreamReader nesnesi oluşturduk.
            string yazi = sw.ReadLine();

            if (yazi == null)
            {
                MessageBox.Show("harita boşş");
                for (int i = 0; i < 20; i++)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        kutu a = new kutu();
                        a.Size      = new Size(40, 40);
                        a.Location  = new Point(i * 40, j * 40);
                        a.BackColor = Color.DarkSlateGray;
                        a.Tag       = "bos";
                        panel1.Controls.Add(a);
                        a.Click += A_Click;
                    }
                }
            }
            while (yazi != null)
            {
                for (int i = 0; i < 20; i++)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        int    posX   = Convert.ToInt32(yazi.Split(',')[0]);
                        int    posY   = Convert.ToInt32(yazi.Split(',')[1]);
                        int    boyutX = Convert.ToInt32(yazi.Split(',')[2]);
                        int    boyutY = Convert.ToInt32(yazi.Split(',')[3]);
                        string tag    = yazi.Split(',')[4];

                        kutu a = new kutu();
                        a.Location = new Point(posX, posY);
                        a.Size     = new Size(boyutX, boyutY);
                        a.Tag      = tag;
                        panel1.Controls.Add(a);
                        if (tag == "kutu")
                        {
                            a.BackColor = Color.Green;
                        }
                        else if (tag == "bomba")
                        {
                            a.BackColor = Color.Blue;
                        }
                        else if (tag == "mayin")
                        {
                            a.BackColor = Color.Red;
                        }
                        else if (tag == "iskele")
                        {
                            a.BackColor = Color.DarkGray;
                        }

                        else
                        {
                            a.BackColor = Color.DarkSlateGray;
                        }
                        // MessageBox.Show(tag);

                        a.Click += A_Click;
                        yazi     = sw.ReadLine();
                    }
                }
            }
            //Satır satır okuma işlemini gerçekleştirdik ve ekrana yazdırdık
            //Son satır okunduktan sonra okuma işlemini bitirdik
            sw.Close();
            fs.Close();
            //İşimiz bitince kullandığımız nesneleri iade ettik.
        }
Exemplo n.º 6
0
        public void etrafinaBak(kutu kutumuz)
        {
            int adet = 0;

            foreach (kutu item in tumKutular)
            {
                if (kutumuz.Right == item.Left &&
                    kutumuz.Top == item.Top)
                {
                    if (item.Tag.ToString() == "mayin")
                    {
                        adet++;
                    }
                }
                if (kutumuz.Left == item.Right &&
                    kutumuz.Top == item.Top)
                {
                    //item.Text = "sol";
                    if (item.Tag.ToString() == "mayin")
                    {
                        adet++;
                    }
                }
                if (kutumuz.Top == item.Bottom &&
                    kutumuz.Left == item.Left)
                {
                    //item.Text = "ust";
                    if (item.Tag.ToString() == "mayin")
                    {
                        adet++;
                    }
                }
                if (kutumuz.Bottom == item.Top &&
                    kutumuz.Left == item.Left)
                {
                    //item.Text = "alt";
                    if (item.Tag.ToString() == "mayin")
                    {
                        adet++;
                    }
                }

                //////////////////////////////////////////////////
                if (kutumuz.Top == item.Bottom &&
                    kutumuz.Left == item.Left + 40)
                {
                    // item.Text = "sol ust";
                    if (item.Tag.ToString() == "mayin")
                    {
                        adet++;
                    }
                }
                if (kutumuz.Top == item.Bottom &&
                    kutumuz.Left == item.Left - 40)
                {
                    // item.Text = "sag ust";
                    if (item.Tag.ToString() == "mayin")
                    {
                        adet++;
                    }
                }
                if (kutumuz.Bottom == item.Top &&
                    kutumuz.Left - 40 == item.Left)
                {
                    //item.Text = "sol alt";
                    if (item.Tag.ToString() == "mayin")
                    {
                        adet++;
                    }
                }
                if (kutumuz.Bottom == item.Top &&
                    kutumuz.Left + 40 == item.Left)
                {
                    //   item.Text = "sag alt";
                    if (item.Tag.ToString() == "mayin")
                    {
                        adet++;
                    }
                }
                //if (adet > 0)
                //{
                //    // MessageBox.Show(kutumuz.Location.ToString());
                //    // kutumuz.Text = adet.ToString();
                //    Label deger = new Label();
                //    deger.Location = kutumuz.Location;
                //    deger.Size = kutumuz.Size;
                //    deger.Text = adet.ToString();
                //    deger.ForeColor = Color.Yellow;
                //    deger.Font = new Font("Arial", 15, FontStyle.Bold);

                //    panel2.Controls.Add(deger);
                //    deger.BringToFront();


                //}

                //kutumuz.tiklandiMi = true;
                //kutumuz.BackgroundImage = null;
                kutumuz.deger = adet;

                if (adet > 0)
                {
                    Label degerlb = new Label();
                    degerlb.Location  = kutumuz.Location;
                    degerlb.Size      = new Size(40, 40);
                    degerlb.Text      = kutumuz.deger.ToString();
                    degerlb.ForeColor = Color.White;
                    degerlb.Parent    = kutumuz;
                    degerlb.BackColor = Color.Transparent;
                    degerlb.Font      = new Font("Arial", 25, FontStyle.Bold);
                    //gelen.BackgroundImage = mayintarlasi.Properties.Resources.kutu2;
                    panel2.Controls.Add(degerlb);
                    degerlb.BringToFront();
                    //  gelen.deger--;
                    kutumuz.tiklandiMi = true;
                    // MessageBox.Show(gelen.deger.ToString());
                }
            }
        }
Exemplo n.º 7
0
        private void İtem_Click(object sender, EventArgs e)
        {
            // MessageBox.Show("tuıklandı");
            kutu gelen = (kutu)sender;

            if (gelen.Tag.ToString() != "bos")
            {
                if ((gelen.Top == karakter.Bottom && gelen.Left == karakter.Left) ||
                    (gelen.Bottom == karakter.Top && gelen.Left == karakter.Left) ||
                    (gelen.Top == karakter.Top && karakter.Right == gelen.Left) ||
                    (gelen.Top == karakter.Top && karakter.Left == gelen.Right) ||
                    (gelen.Top == karakter.Bottom && gelen.Left == karakter.Left + 40) ||
                    (karakter.Top == gelen.Bottom && karakter.Left == gelen.Left + 40) ||
                    (karakter.Top == gelen.Bottom && karakter.Left == gelen.Left - 40) ||
                    (gelen.Top == karakter.Bottom && gelen.Left == karakter.Left - 40)
                    )
                {
                    panel2.Controls.Remove(okum);
                    okFirlat  = true;
                    okKonum   = new Point(gelen.Location.X, gelen.Location.Y);
                    okum      = new PictureBox();
                    okum.Size = new Size(20, 20);
                    okum.BackgroundImageLayout = ImageLayout.Stretch;
                    okum.BackgroundImage       = mayintarlasi.Properties.Resources.deneme;


                    okum.BackColor = Color.Transparent;

                    panel2.Controls.Add(okum);
                    okum.Location = karakter.Location;
                    okum.BringToFront();

                    if (gelen.Tag.ToString() == "mayin")
                    {
                        MessageBox.Show("mayınnnnnnn");
                        level--;
                        baslangic();
                    }
                    else
                    {
                        if (gelen.Tag.ToString() == "bomba")
                        {
                            gelen.BackgroundImageLayout = ImageLayout.Stretch;
                            gelen.BackgroundImage       = mayintarlasi.Properties.Resources.bomba1;
                        }
                        else
                        {
                            gelen.BackgroundImage = null;
                            etrafinaBak(gelen);
                        }

                        gelen.tiklandiMi = true;



                        //gelen.tiklandiMi = true;
                        //if (gelen.tiklandiMi == true)
                        //{
                        //    etrafinaBak(gelen);
                        //    //gelen.BackgroundImage = null;

                        //}
                    }
                }
            }
        }
Exemplo n.º 8
0
        public void A_Tick(object sender, EventArgs e)
        {
            if (this.kalanSure > 0)
            {
                this.kalanSure--;
            }
            else
            {
                // this.patladi = true;

                patlamaalani.Location              = new Point(this.Location.X - 40, this.Location.Y - 40);
                patlamaalani.Size                  = new Size(120, 120);
                patlamaalani.BackgroundImage       = mayintarlasi.Properties.Resources.deneme;
                patlamaalani.BackgroundImageLayout = ImageLayout.Stretch;
                this.panell.Controls.Add(patlamaalani);
                patlamaalani.BringToFront();

                if (indir > 0)
                {
                    indir--;
                }
                else
                {
                    panell.Controls.Remove(patlamaalani);
                    this.BackgroundImage = null;
                    foreach (Control item in panell.Controls)
                    {
                        if (item is kutu)
                        {
                            if (item.Tag.ToString() == "mayin" ||
                                item.Tag.ToString() == "kutu" ||
                                item.Tag.ToString() == "bomba" ||
                                item.Tag.ToString() == "karakter")
                            {
                                kutu kutum = (kutu)item;
                                if ((item.Left <= patlamaalani.Right - 40) &&
                                    (item.Left >= patlamaalani.Left) && item.Top == patlamaalani.Top
                                    )
                                {
                                    form.etrafinaBak(kutum);
                                    kutum.tiklandiMi = true;
                                    //kutum.Tag = "bos";
                                    kutum.BackgroundImage = null;
                                }
                                if ((item.Left <= patlamaalani.Right - 40) &&
                                    (item.Left >= patlamaalani.Left) && item.Top - 40 == patlamaalani.Top
                                    )
                                {
                                    form.etrafinaBak(kutum);
                                    kutum.tiklandiMi = true;
                                    //kutum.Tag = "bos";
                                    kutum.BackgroundImage = null;
                                }
                                if ((item.Left <= patlamaalani.Right - 40) &&
                                    (item.Left >= patlamaalani.Left) && item.Top - 80 == patlamaalani.Top
                                    )
                                {
                                    form.etrafinaBak(kutum);
                                    kutum.tiklandiMi = true;
                                    //kutum.Tag = "bos";
                                    kutum.BackgroundImage = null;
                                }
                            }
                        }
                    }

                    this.sureSifirla();
                }
            }
        }