Example #1
0
        private void Tmr_Uretici_Tick(object sender, EventArgs e)
        {
            Point point = new Point(rnd.Next(20, container.Width - 70), 20);
            Ucak  ucak  = new Ucak(point, this.container);

            Ucaklar.Add(ucak);
        }
Example #2
0
        private void TmrUretici_Tick(object sender, EventArgs e)
        {
            Point point = new Point()
            {
                X = rnd.Next(60, tasiyici.Width - 120),
                Y = 0
            };
            Ucak ucak = new Ucak(point);

            ucak.ResimKutusu.Click += ucakresim_click;
            Ucaklar.Add(ucak);

            tasiyici.Controls.Add(ucak.ResimKutusu);
        }
Example #3
0
        private void TmrKontrol_Tick(object sender, EventArgs e)
        {
            if (durduMu)
            {
                tmrMermi.Stop();
                tmrUcak.Stop();
                tmrUretici.Stop();
            }
            else
            {
                tmrMermi.Start();
                tmrUcak.Start();
                tmrUretici.Start();
            }
            roketKonumları.Clear();
            foreach (var ucak in Ucaklar)
            {
                Rectangle ur      = new Rectangle();
                Rectangle mr      = new Rectangle();
                bool      vurdumu = false;
                if (ucak.ResimKutusu.Location.Y + ucak.ResimKutusu.Height > tasiyici.Height - 70)
                {
                    OyunDurduMu = true;
                    tmrKontrol.Stop();
                    tmrMermi.Stop();
                    tmrUcak.Stop();
                    tmrUretici.Stop();
                }
                foreach (var roket in this.Ucaksavar.Roketler)
                {
                    ur.X      = ucak.ResimKutusu.Left;
                    ur.Y      = ucak.ResimKutusu.Top;
                    ur.Height = ucak.ResimKutusu.Height;
                    ur.Width  = ucak.ResimKutusu.Width;

                    mr.X      = roket.ResimKutusu.Left;
                    mr.Y      = roket.ResimKutusu.Top;
                    mr.Height = roket.ResimKutusu.Height;
                    mr.Width  = roket.ResimKutusu.Width;
                    if (ur.IntersectsWith(mr))
                    {
                        tasiyici.Controls.Remove(ucak.ResimKutusu);
                        tasiyici.Controls.Remove(roket.ResimKutusu);
                        Ucaklar.Remove(ucak);
                        Ucaksavar.Roketler.Remove(roket);
                        Skor++;
                        vurdumu = true;
                        SoundPlayer soundPlayer = new SoundPlayer(Properties.Resources.bomb_small);
                        soundPlayer.Play();

                        if (Skor % 10 == 0 && Skor > 1 && tmrUretici.Interval > 2)
                        {
                            tmrUretici.Interval -= 1;
                        }

                        break;
                    }
                }
                if (vurdumu)
                {
                    break;
                }
            }

            foreach (var item in this.Ucaksavar.Roketler)
            {
                if (item.ResimKutusu.Location.Y < 0)
                {
                    this.Ucaksavar.Roketler.Remove(item);
                    tasiyici.Controls.Remove(item.ResimKutusu);
                    break;
                }
            }

            foreach (var item in Ucaksavar.Roketler)
            {
                Konumlar yenikonum = new Konumlar()
                {
                    x    = item.ResimKutusu.Location.X.ToString(),
                    y    = item.ResimKutusu.Location.Y.ToString(),
                    skor = this.Skor.ToString()
                };
                roketKonumları.Add(yenikonum);
            }
            foreach (var item in Ucaklar)
            {
                Konumlar yenikonum = new Konumlar()
                {
                    z    = item.ResimKutusu.Location.X.ToString(),
                    c    = item.ResimKutusu.Location.Y.ToString(),
                    skor = this.Skor.ToString()
                };
                roketKonumları.Add(yenikonum);
            }
        }
Example #4
0
        private void Tmr_Kontrol_Tick(object sender, EventArgs e)
        {
            foreach (Ucak ucak in Ucaklar)
            {
                Rectangle ru = new Rectangle();
                Rectangle rr = new Rectangle();
                if (ucak.Resim.Location.Y + ucak.Resim.Height > container.Height - 70)
                {
                    tmr_Kontrol.Stop();
                    tmr_Roket.Stop();
                    tmr_Ucak.Stop();
                    tmr_Uretici.Stop();
                    DialogResult secenek = MessageBox.Show($"Skorunuz: {skor}\nTekrar oynamak ister misiniz?", "Bilgilendirme Penceresi", MessageBoxButtons.YesNo);
                    if (secenek == DialogResult.Yes)
                    {
                        Application.Restart();
                    }
                    else
                    {
                        Application.Exit();
                    }
                }
                ru.Location = ucak.Resim.Location;
                ru.Width    = ucak.Resim.Width;
                ru.Height   = ucak.Resim.Height;
                bool vurduMu = false;
                foreach (Roket roket in UcakSavar.Roketler)
                {
                    rr.Location = roket.Resim.Location;
                    rr.Width    = roket.Resim.Width;
                    rr.Height   = roket.Resim.Width;

                    //if (ru.IntersectsWith(rr))
                    //{
                    //    vurduMu = true;
                    //    container.Controls.Remove(ucak.Resim);
                    //    container.Controls.Remove(roket.Resim);
                    //    Ucaklar.Remove(ucak);
                    //    UcakSavar.Roketler.Remove(roket);
                    //    SoundPlayer soundPlayer = new SoundPlayer(Properties.Resources.bomb_small);
                    //    soundPlayer.Play();
                    //    break;
                    //}

                    if (roket.Resim.Bounds.IntersectsWith(ucak.Resim.Bounds))
                    {
                        vurduMu = true;
                        container.Controls.Remove(ucak.Resim);
                        container.Controls.Remove(roket.Resim);
                        Ucaklar.Remove(ucak);
                        UcakSavar.Roketler.Remove(roket);
                        SoundPlayer soundPlayer = new SoundPlayer(Properties.Resources.bomb_small);
                        soundPlayer.Play();
                        skor++;
                        break;
                    }
                }
                if (vurduMu)
                {
                    break;
                }
            }
            foreach (Roket roket in UcakSavar.Roketler)
            {
                if (roket.Resim.Location.Y < 0)
                {
                    UcakSavar.Roketler.Remove(roket);

                    this.container.Controls.Remove(roket.Resim);
                    break;
                }
            }
        }
Example #5
0
        private void Tmr_Kontrol_Tick(object sender, EventArgs e)
        {
            foreach (Ucak ucak in Ucaklar)
            {
                Rectangle ru = new Rectangle();
                Rectangle rr = new Rectangle();

                if (ucak.Resim.Location.Y + ucak.Resim.Height > container.Height - 70)
                {
                    tmr_Kontrol.Stop();
                    tmr_Ucak.Stop();
                    tmr_Uretici.Stop();
                    tmr_Roket.Stop();
                }

                ru.Location = ucak.Resim.Location;
                ru.Width    = ucak.Resim.Width;
                ru.Height   = ucak.Resim.Height;
                bool vurduMu = false;
                foreach (Roket roket in UcakSavar.Roketler)
                {
                    rr.Location = roket.Resim.Location;
                    rr.Width    = roket.Resim.Width;
                    rr.Height   = roket.Resim.Height;

                    //if (ru.IntersectsWith(rr))
                    //{
                    //    vurduMu = true;
                    //    container.Controls.Remove(ucak.Resim);
                    //    container.Controls.Remove(roket.Resim);
                    //    Ucaklar.Remove(ucak);
                    //    UcakSavar.Roketler.Remove(roket);
                    //    SoundPlayer soundPlayer = new SoundPlayer(Properties.Resources.bomb_small);
                    //    soundPlayer.Play();
                    //    break;
                    //}
                    if (roket.Resim.Bounds.IntersectsWith(ucak.Resim.Bounds))
                    {
                        vurduMu = true;
                        container.Controls.Remove(ucak.Resim);
                        container.Controls.Remove(roket.Resim);
                        Ucaklar.Remove(ucak);
                        UcakSavar.Roketler.Remove(roket);
                        SoundPlayer soundPlayer = new SoundPlayer(Properties.Resources.bomb_small);
                        soundPlayer.Play();
                        break;
                    }
                }
                if (vurduMu)
                {
                    break;
                }
            }

            foreach (Roket roket in UcakSavar.Roketler)
            {
                if (roket.Resim.Location.Y < 0)
                {
                    UcakSavar.Roketler.Remove(roket);
                    this.container.Controls.Remove(roket.Resim);
                    break;
                }
            }
        }