Ejemplo n.º 1
0
        void HitChicken(Class_Arrow arrow)
        {
            if (arrow.nivel == 1)
            {
                for (int i = 0; i < chickens.Count; i++)
                {
                    if (chickens[i].location <= 4)
                    {
                        if (arrow.X >= chickens[i].X && arrow.X <= chickens[i].X + chickens[i].Width)
                        {
                            if (arrow.Y >= chickens[i].Y && arrow.Y <= chickens[i].Y + chickens[i].Height)
                            {
                                if (!chickens[i].Baby)
                                {
                                    Score++;
                                    label_Punctaj.Text = Score.ToString();

                                    frec[chickens[i].location] = 0;
                                    chickens.RemoveAt(i);

                                    timer_Arrow.Stop();
                                    Trage = false;
                                    nrGaini--;

                                    if (Sound)
                                    {
                                        soundPlayer_Chicken_Hurt.Play();
                                    }
                                }
                                else
                                {
                                    if (Sound)
                                    {
                                        soundPlayer_Chicken_Hurt.Play();
                                    }

                                    DataSet_AccountsTableAdapters.QueriesTableAdapter queriesTableAdapter = new DataSet_AccountsTableAdapters.QueriesTableAdapter();

                                    int nrPui = (int)queriesTableAdapter.Get_NrPui(Id_User);
                                    queriesTableAdapter.Update_NrPui(nrPui + 1, Id_User);


                                    timer_Arrow.Stop();
                                    timer_Chicken.Stop();

                                    Hide();

                                    Form_GameOver form_GameOver = new Form_GameOver(Score);

                                    form_GameOver.ShowDialog();

                                    Close();
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < chickens.Count; i++)
                {
                    if (chickens[i].location >= 5)
                    {
                        if (arrow.X >= chickens[i].X && arrow.X <= chickens[i].X + chickens[i].Width)
                        {
                            if (arrow.Y >= chickens[i].Y && arrow.Y <= chickens[i].Y + chickens[i].Height)
                            {
                                if (!chickens[i].Baby)
                                {
                                    Score++;
                                    label_Punctaj.Text = Score.ToString();

                                    frec[chickens[i].location] = 0;
                                    chickens.RemoveAt(i);

                                    timer_Arrow.Stop();
                                    Trage = false;

                                    nrGaini--;

                                    if (Sound)
                                    {
                                        soundPlayer_Chicken_Hurt.Play();
                                    }
                                }
                                else
                                {
                                    if (Sound)
                                    {
                                        soundPlayer_Chicken_Hurt.Play();
                                    }

                                    DataSet_AccountsTableAdapters.QueriesTableAdapter queriesTableAdapter = new DataSet_AccountsTableAdapters.QueriesTableAdapter();

                                    int nrPui = (int)queriesTableAdapter.Get_NrPui(Id_User);
                                    queriesTableAdapter.Update_NrPui(nrPui + 1, Id_User);

                                    timer_Arrow.Stop();
                                    timer_Chicken.Stop();

                                    Hide();

                                    Form_GameOver form_GameOver = new Form_GameOver(Score);

                                    form_GameOver.ShowDialog();

                                    Close();
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void timer_Arrow_Tick(object sender, EventArgs e)
        {
            if (arrow.nivel == 1)
            {
                if (arrow.Y <= 415)
                {
                    timer_Arrow.Stop();
                    Trage = false;

                    nrSageti--;

                    if (nrSageti == 2)
                    {
                        pictureBox_Arrow3.Image = Properties.Resources.Icon_Arrow_Empty;
                    }
                    if (nrSageti == 1)
                    {
                        pictureBox_Arrow2.Image = Properties.Resources.Icon_Arrow_Empty;
                    }
                    if (nrSageti == 0)
                    {
                        pictureBox_Arrow1.Image = Properties.Resources.Icon_Arrow_Empty;
                    }

                    if (nrSageti == 0)
                    {
                        timer_Arrow.Stop();
                        timer_Chicken.Stop();

                        Hide();

                        Form_GameOver form_GameOver = new Form_GameOver(Score);

                        form_GameOver.ShowDialog();

                        Close();
                    }

                    return;
                }
            }

            if (arrow.nivel == 2)
            {
                if (arrow.Y <= 370)
                {
                    timer_Arrow.Stop();
                    Trage = false;

                    nrSageti--;

                    if (nrSageti == 2)
                    {
                        pictureBox_Arrow3.Image = Properties.Resources.Icon_Arrow_Empty;
                    }
                    if (nrSageti == 1)
                    {
                        pictureBox_Arrow2.Image = Properties.Resources.Icon_Arrow_Empty;
                    }
                    if (nrSageti == 0)
                    {
                        pictureBox_Arrow1.Image = Properties.Resources.Icon_Arrow_Empty;
                    }

                    if (nrSageti == 0)
                    {
                        timer_Arrow.Stop();
                        timer_Chicken.Stop();

                        Hide();

                        Form_GameOver form_GameOver = new Form_GameOver(Score);

                        form_GameOver.ShowDialog();

                        Close();
                    }

                    return;
                }
            }

            HitChicken(arrow);

            arrow.Y -= 10;

            pictureBox_Fundal.Refresh();
        }