Beispiel #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            this.tajmerStarter++;

            if(this.tajmerStarter == 30)
                lbl_ups.Text="";

            if (this.tajmerStarter == 10)
            {
                int a = -1;
                while(a==-1){
                    Random r = new Random();
                    int k = r.Next()%5;
                    if (pagjaat[k] == false)
                    {
                        a = k;
                        pagjaat[k] = true;
                    }
                }
                Zadaca zz = new Zadaca(1,a);
                live.Add(zz);
                label2.Text = zz.o;
                label3.Text = zz.s;
                label2.Location = new System.Drawing.Point((zz.kojred+1) * (int)((this.Width / 8.7)), 20);
                label3.Location = new System.Drawing.Point((zz.kojred + 1) * (int)((this.Width / 8.7)) + 15, 15);

                timer2.Start();
            }

            else if (this.tajmerStarter == 350){     //35 sec najubavo
                int a = -1;
                while (a == -1)
                {
                    Random r = new Random();
                    int k = r.Next() % 5;
                    if (pagjaat[k] == false)
                    {
                        a = k;
                        pagjaat[k] = true;
                    }
                }
                Zadaca zz = new Zadaca(2,a);
                live.Add(zz);
                label4.Text = zz.o;
                label5.Text = zz.s;
                label4.Location = new System.Drawing.Point((zz.kojred+1) * (int)((this.Width / 8.7)), 20);
                label5.Location = new System.Drawing.Point((zz.kojred + 1) * (int)((this.Width / 8.7)) + 15, 15);
                //timer3.Start();
             }

            else if (this.tajmerStarter == 600){    //60 sec najubavo
                int a = -1;
                while (a == -1)
                {
                    Random r = new Random();
                    int k = r.Next() % 5;
                    if (pagjaat[k] == false)
                    {
                        a = k;
                        pagjaat[k] = true;
                    }
                }
                Zadaca zz = new Zadaca(3,a);
                live.Add(zz);
                label6.Text = zz.o;
                label7.Text = zz.s;
                label6.Location = new System.Drawing.Point((zz.kojred + 1) * (int)((this.Width / 8.7)), 20);
                label7.Location = new System.Drawing.Point((zz.kojred + 1) * (int)((this.Width / 8.7)) + 15, 15);
                //timer4.Start();
            }

            foreach (Zadaca z in live)
            {
                z.tajmerce -= 100;

                if (z.tajmerce == 0)
                {
                    lifs--;
                    lif.Text = string.Format("LIVES: {0}", lifs);
                    if(lifs==2)
                        lif.ForeColor = Color.DarkGoldenrod;
                    else if(lifs==1)
                        lif.ForeColor = Color.DarkRed;

                    tajmerStarter=0;
                    live.Clear();
                    //live = new List<Zadaca>();

                    label2.Text = "";
                    label3.Text = "";
                    label4.Text = "";
                    label5.Text = "";
                    label6.Text = "";
                    label7.Text = "";
                    lbl_ups.Text = "OOPS..";
                    for (int i = 0; i < 5; i++)
                        pagjaat[i] = false;

                    break;
                }
            }

            if (lifs == 0) {
                lif.ForeColor = Color.Red;
                timer1.Stop();
                timer2.Stop();
                live.Clear();
                tajmerStarter = 0;
                label2.Text = "";           //brisi
                label3.Text = "";           //brisi
                label4.Text = "";           //brisi
                label5.Text = "";           //brisi
                label6.Text = "";           //brisi
                label7.Text = "";
                lbl_ups.Text = "";             //istoo...
                started = false;
                btn_start.Show();

                Graphics g = Graphics.FromImage(doubleBuffer);
                g.Clear(Color.White);
                graphics.DrawImageUnscaled(doubleBuffer, 0, 0);
                MessageBox.Show(label1.Text, "GAME OVER");
                label1.Text = string.Format("FINISHED");
            }
        }
Beispiel #2
0
        private void pomosna()
        {
            if (resenie.Length == 0) return;
            int r = int.Parse(resenie);
            bool da = false;
            List<Zadaca> brisi = new List<Zadaca>();
            if (live.Count != 0)
                foreach (Zadaca z in live)
                {
                    if (z.result == r)
                    {
                        score += scoreAppender;
                        scoreAppender++;
                        label1.Text = string.Format("Your score: {0}", score);
                        brisi.Add(z);
                        da = true;
                    }

                }
            if (da)
            {
                foreach (Zadaca z in brisi)
                {
                    if (z.level == 1)
                    {
                        int a = -1;
                        while (a == -1)
                        {
                            Random q = new Random();
                            int k = q.Next() % 5;
                            if (pagjaat[k] == false)
                            {
                                a = k;
                                pagjaat[k] = true;
                            }
                        }
                        Zadaca zz = new Zadaca(1, a);
                        live.Add(zz);
                        label2.Text = zz.o;
                        label3.Text = zz.s;
                    }
                    else if (z.level == 2)
                    {
                        int a = -1;
                        while (a == -1)
                        {
                            Random q = new Random();
                            int k = q.Next() % 5;
                            if (pagjaat[k] == false)
                            {
                                a = k;
                                pagjaat[k] = true;
                            }
                        }
                        Zadaca zz = new Zadaca(2, a);
                        live.Add(zz);
                        label4.Text = zz.o;
                        label5.Text = zz.s;
                    }
                    else if (z.level == 3)
                    {
                        int a = -1;
                        while (a == -1)
                        {
                            Random q = new Random();
                            int k = q.Next() % 5;
                            if (pagjaat[k] == false)
                            {
                                a = k;
                                pagjaat[k] = true;
                            }
                        }
                        Zadaca zz = new Zadaca(3, a);
                        live.Add(zz);
                        label6.Text = zz.o;
                        label7.Text = zz.s;
                    }
                    pagjaat[z.kojred] = false;
                    live.Remove(z);
                }
            }
            if (!da)
            {
                score -= scoreAppender;
                if (score < 0) score = 0;
                label1.Text = string.Format("Your score: {0}", score);
                //this.Invalidate();
            }

            button14_Click(this, new EventArgs());
        }