コード例 #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            gecenSure    = gecenSure + 1;
            label19.Text = gecenSure + " SN";

            //TAVUK KODLARI BAŞLANGIÇ
            if (progressBar1.Value > 2) //Tavuk canı ikiden büyükse her saniye 2 birim can azalt
            {
                progressBar1.Value = t1.yemAzalt(progressBar1.Value, 2);
            }
            else
            {
                t1.tavukSes++;
                if (t1.tavukSes == 1)  //Tavuk ölürken bir kere ses çalması için koşul
                {
                    player.SoundLocation = @"C:\Users\Merve\Desktop\OOP\ÖDEVLER\Proje\tavuk.wav";
                    player.Play();
                }

                progressBar1.Value = 0;
                label11.Text       = "ÖLDÜ";
                button5.Enabled    = false;
            }

            if (gecenSure % 3 == 0)          //3 saniyede bir tavuk yumurtası üretmek için koşul
            {
                if (button5.Enabled == true) //Tavuk ölmediyse buton aktiftir. Buton aktifse yumurta miktarını arttır.
                {
                    t1.yumurtaMiktari++;
                }
            }
            label15.Text = Convert.ToString(t1.yumurtaMiktari) + " ADET";
            //TAVUK KODLARI BİTİŞ

            //ÖRDEK KODLARI BAŞLANGIÇ
            if (progressBar2.Value > 1)  //Ördek canı birden büyükse her saniye 3 birim can azalt
            {
                progressBar2.Value = o1.yemAzalt(progressBar2.Value, 3);
            }
            else
            {
                o1.ordekSes++;
                if (o1.ordekSes == 1) //Ördek ölürken bir kere ses çalması için koşul
                {
                    player.SoundLocation = @"C:\Users\Merve\Desktop\OOP\ÖDEVLER\Proje\ordek.wav";
                    player.Play();
                }

                progressBar2.Value = 0;
                label12.Text       = "ÖLDÜ";
                button6.Enabled    = false;
            }

            if (gecenSure % 5 == 0)          //5 saniyede bir ördek yumurtası üretmek için koşul
            {
                if (button6.Enabled == true) //Ördek ölmediyse buton aktiftir. Buton aktifse yumurta miktarını arttır.
                {
                    o1.yumurtaMiktari++;
                }
            }
            label17.Text = Convert.ToString(o1.yumurtaMiktari) + " ADET";
            //ÖRDEK KODLARI BİTİŞ

            //İNEK KODLARI BAŞLANGIÇ
            if (progressBar3.Value > 4)  //İnek canı dörtten büyükse her saniye 8 birim can azalt
            {
                progressBar3.Value = i1.yemAzalt(progressBar3.Value, 8);
            }
            else
            {
                i1.inekSes++;
                if (i1.inekSes == 1)  //İnek ölürken bir kere ses çalması için koşul
                {
                    player.SoundLocation = @"C:\Users\Merve\Desktop\OOP\ÖDEVLER\Proje\inek.wav";
                    player.Play();
                }
                progressBar3.Value = 0;
                label13.Text       = "ÖLDÜ";
                button7.Enabled    = false;
            }

            if (gecenSure % 8 == 0)          //8 saniyede bir süt üretmesi için koşul
            {
                if (button7.Enabled == true) //İnek ölmediyse buton aktiftir. Buton aktifse süt miktarını arttır.
                {
                    i1.sutMiktari++;
                }
            }
            label16.Text = Convert.ToString(i1.sutMiktari) + " KG";
            //İNEK KODLARI BİTİŞ

            //KEÇİ KODLARI BAŞLANGIÇ
            if (progressBar4.Value > 4)  //Keçi canı dörtten büyükse her saniye 6 birim can azalt
            {
                progressBar4.Value = k1.yemAzalt(progressBar4.Value, 6);
            }
            else
            {
                k1.keciSes++;
                if (k1.keciSes == 1)  //Keçi ölürken bir kere ses çalması için koşul
                {
                    player.SoundLocation = @"C:\Users\Merve\Desktop\OOP\ÖDEVLER\Proje\keci.wav";
                    player.Play();
                }
                progressBar4.Value = 0;
                label14.Text       = "ÖLDÜ";
                button8.Enabled    = false;
            }

            if (gecenSure % 7 == 0)          //7 saniyede bir süt üretmek için koşul
            {
                if (button8.Enabled == true) //Keçi ölmediyse buton aktiftir. Buton aktifse süt miktarını arttır.
                {
                    k1.sutMiktari++;
                }
            }
            label18.Text = Convert.ToString(k1.sutMiktari) + " KG";
            //KEÇİ KODLARI BİTİŞ
        }