private void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            strela.Play();
            //if (e.X >= eden.x && e.Y >= eden.y && e.X < eden.x + eden.slika.Width && e.Y < eden.y + eden.slika.Height)

            foreach (WhiteWalker los in (gm.lista1))
            {
                if (e.X >= los.x && e.Y >= los.y && e.X < los.x + 60 && e.Y < los.y + 100)
                {
                    WW = los;
                    isHit = true;
                    los.zvuk.Play();
                    score++;

                }

            }

            if (isHit)
            {

                gm.lista1.Remove(WW);
                Invalidate();

            }

            foreach (Night_sWatch nw in gm.lista2)
            {
                if (e.X >= nw.x && e.Y >= nw.y && e.X < nw.x + 100 && e.Y < nw.y + 80)
                {
                    NW = nw;
                    isHit2 = true;
                    nw.zvuk.Play();
                    score = score - 5;

                    lives--;

                    if (lives == 0)
                    {
                        tTopka.Stop();
                        topkaCrtaj.Stop();
                        tWave.Stop();
                        tLvL.Stop();
                        t.Stop();
                        t1.Stop();
                        t2.Stop();
                        t3.Stop();
                        tt.Stop();
                        tt1.Stop();
                        tt2.Stop();
                        tt3.Stop();
                        ttt.Stop();
                        ttt1.Stop();
                        ttt2.Stop();
                        ttt3.Stop();
                        this.Hide();
                        GameOver gmo = new GameOver();
                        gmo.ShowDialog();

                        this.Close();

                    }
                }

            }
            if (isHit2)
            {

                gm.lista2.Remove(NW);

                Invalidate();

            }
            foreach (CannonBall cb in (gm.lista4))
            {
                if (e.X >= cb.x && e.Y >= cb.y && e.X < cb.x + 65 && e.Y < cb.y + 60)
                {
                    CB = cb;
                    isHit3 = true;
                    //cb.zvuk.Play();
                    score=score+2;

                }

            }

            if (isHit3)
            {

                gm.lista4.Remove(CB);
                Invalidate();

            }
        }
        //функција за создавање на објект од класата WhiteWalker повикувана на одреден интервал
        private void TimerEventWW(Object myObject, EventArgs myEventArgs)
        {
            if (lvl1 == true)
            {
                WhiteWalker ww = new WhiteWalker(rnd.Next(50, 900), rnd.Next(50, 450));
                gm.lista1.Add(ww);

                if (((gm.lista1.Count) + (gm.lista3.Count)) > 15)
                {
                    t.Stop();
                    t2.Stop();
                    tWave.Stop();
                    tLvL.Stop();
                    this.Hide();
                    GameOver gmo = new GameOver();
                    gmo.ShowDialog();

                    this.Close();

                }

                Invalidate();
            }

            else if (lvl2 == true)
            {
                t.Stop();
                tt.Start();
                WhiteWalker ww = new WhiteWalker(rnd.Next(50, 900), rnd.Next(50, 450));
                gm.lista1.Add(ww);

                if (((gm.lista1.Count) + (gm.lista3.Count)) > 15)
                {
                    tt.Stop();
                    tt2.Stop();
                    tWave.Stop();
                    tLvL.Stop();
                    this.Hide();
                    GameOver gmo = new GameOver();
                    gmo.ShowDialog();

                    this.Close();

                }

                Invalidate();
            }

            else if (lvl3 == true)
            {
                tt.Stop();
                ttt.Start();
                WhiteWalker ww = new WhiteWalker(rnd.Next(50, 900), rnd.Next(50, 450));
                gm.lista1.Add(ww);

                if (((gm.lista1.Count) + (gm.lista3.Count)) > 15)
                {
                    ttt.Stop();
                    ttt2.Stop();
                    tWave.Stop();
                    tLvL.Stop();
                    this.Hide();
                    GameOver gmo = new GameOver();
                    gmo.ShowDialog();

                    this.Close();

                }

                Invalidate();
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            BackgroundWorker bw = new BackgroundWorker();
            BackgroundWorker bw2 = new BackgroundWorker();
            BackgroundWorker bw3 = new BackgroundWorker();
            BackgroundWorker bw4 = new BackgroundWorker();
            BackgroundWorker bw5 = new BackgroundWorker();
            BackgroundWorker bw6 = new BackgroundWorker();
             //this allows our worker to report progress during work
            bw.WorkerReportsProgress = true;
            bw2.WorkerReportsProgress = true;
            bw3.WorkerReportsProgress = true;
            bw4.WorkerReportsProgress = true;
            bw5.WorkerReportsProgress = true;
            bw6.WorkerReportsProgress = true;
            // what to do in the background thread
            bw.DoWork += new DoWorkEventHandler(
            delegate(object o, DoWorkEventArgs args)
            {
                BackgroundWorker b = o as BackgroundWorker;

                while (bw.WorkerReportsProgress == true)
                {
                    b.ReportProgress(1);
                    System.Threading.Thread.Sleep(500);
                }

            });

            // what to do when progress changed (update the progress bar for example)
            bw.ProgressChanged += new ProgressChangedEventHandler(
            delegate(object o, ProgressChangedEventArgs args)
            {
                if (((gm.lista1.Count) + (gm.lista3.Count)) > 15)//проверка за број на негативни ликови
                {

                    bw.WorkerReportsProgress = false;
                    t.Stop();
                    t2.Stop();
                    tWave.Stop();
                    tTopka.Stop();
                    topkaCrtaj.Stop();
                    tWave.Stop();

                    tLvL.Stop();
                    this.Hide();
                    GameOver gmo = new GameOver();
                    gmo.ShowDialog();

                    this.Close();
                    //ако бројот е поголем од 15 се стопираат сите тајмери и нитки и се отвара формата Game over

                }
                for (int i = 0; i < gm.lista4.Count; i++)
            {
                gm.lista4[i].Move(20, 60, 10, 10);//движење на топката
                gm.proveriUdar();//проверка за удар со објект од Night'sWatch
                lives = lives - gm.poeniTopka;
                //ако имало удар gm.poeniTopka ке биде 1(види класа GMdoc) и бројот на животи ке се намали за 1,а ако немало удар gm.poeniTopka ке биде 0
                if (lives == 0)
                {

                    bw.WorkerReportsProgress = false;

                    tTopka.Stop();
                    topkaCrtaj.Stop();
                    tWave.Stop();
                    tLvL.Stop();
                    t.Stop();
                    t1.Stop();
                    t2.Stop();
                    t3.Stop();
                    tt.Stop();
                    tt1.Stop();
                    tt2.Stop();
                    tt3.Stop();
                    ttt.Stop();
                    ttt1.Stop();
                    ttt2.Stop();
                    ttt3.Stop();
                    this.Hide();
                    GameOver gmo = new GameOver();
                    gmo.ShowDialog();

                    this.Close();

                    //проверка на бројот на животи.Ако е 0 стопирање на сите тајмери и отварање на формата GameOver

                }
                if (gm.lista4[i].x > 1000)
                {
                    gm.lista4[i].kraj = true;
                    //порверка дали топката ја пречекорила границата на формата
                }

            }
            for (int i = gm.lista4.Count - 1; i >= 0; i--)
            {
                if (gm.lista4[i].kraj == true)
                {
                    gm.lista4.RemoveAt(i);
                    //ако ја пречекорила избриши ја
                }

            }
            Invalidate(true);

            });

            bw2.DoWork += new DoWorkEventHandler(
            delegate(object o, DoWorkEventArgs args)
            {
                BackgroundWorker b = o as BackgroundWorker;

                while (bw2.WorkerReportsProgress == true)
                {
                    b.ReportProgress(1);
                    System.Threading.Thread.Sleep(100);
                }

            });

            // what to do when progress changed (update the progress bar for example)
            bw2.ProgressChanged += new ProgressChangedEventHandler(
            delegate(object o, ProgressChangedEventArgs args)
            {

                label6.Text = lives.ToString();

            });

            bw3.DoWork += new DoWorkEventHandler(
               delegate(object o, DoWorkEventArgs args)
               {
               BackgroundWorker b = o as BackgroundWorker;

               while (bw3.WorkerReportsProgress == true)
               {
                   b.ReportProgress(1);
                   System.Threading.Thread.Sleep(100);
               }

               });

            // what to do when progress changed (update the progress bar for example)
            bw3.ProgressChanged += new ProgressChangedEventHandler(
            delegate(object o, ProgressChangedEventArgs args)
            {

                label2.Text = score.ToString();

            });

            bw3.DoWork += new DoWorkEventHandler(
              delegate(object o, DoWorkEventArgs args)
              {
              BackgroundWorker b = o as BackgroundWorker;

              while (bw3.WorkerReportsProgress == true)
              {
              b.ReportProgress(1);
              System.Threading.Thread.Sleep(100);
              }

              });

            // what to do when progress changed (update the progress bar for example)
            bw3.ProgressChanged += new ProgressChangedEventHandler(
            delegate(object o, ProgressChangedEventArgs args)
            {

                label4.Text = ((gm.lista1.Count) + (gm.lista3.Count)).ToString();

            });

            bw5.DoWork += new DoWorkEventHandler(
            delegate(object o, DoWorkEventArgs args)
            {
             BackgroundWorker b = o as BackgroundWorker;

            while (bw5.WorkerReportsProgress == true)
            {
             b.ReportProgress(1);
             System.Threading.Thread.Sleep(1000);
             }

             });

            // what to do when progress changed (update the progress bar for example)
            bw5.ProgressChanged += new ProgressChangedEventHandler(
            delegate(object o, ProgressChangedEventArgs args)
            {

                if (vreme1 == 0)
                { vreme1 = 60; }
                if (vreme1 != 0)
                {
                    vreme1--;

                    label11.Text = vreme1.ToString();

                }
                if (vreme2 == 0)
                { vreme2 = 15; }
                if (vreme2 != 0)
                {
                    vreme2--;

                    label12.Text = vreme2.ToString();

                }

            });

            bw3.RunWorkerAsync();
            bw2.RunWorkerAsync();
            bw.RunWorkerAsync();
            bw4.RunWorkerAsync();
            bw5.RunWorkerAsync();
            bw6.RunWorkerAsync();
        }