コード例 #1
0
ファイル: Form_Game.cs プロジェクト: LeonardRumeghea/Archero
        public Form_Game(Class_Bow bow, Form form, int Id_User)
        {
            InitializeComponent();

            this.bow = bow;

            aim = new Class_Aim(bow.X + bow.Width / 2 - 7, 430);

            form_Start = form;

            this.Id_User = Id_User;

            arrow = new Class_Arrow();

            frec = new int[9];

            for (int i = 1; i <= 8; i++)
            {
                frec[i] = 0;
            }

            rnd      = new Random();
            chickens = new List <Class_Chicken>();

            soundPlayer_Chicken_Hurt  = new SoundPlayer(Properties.Resources.Sound_chicken_Hurt);
            soundPlayer_Chicken_Spawn = new SoundPlayer(Properties.Resources.Shound_Chicken_Spawn);
        }
コード例 #2
0
ファイル: Form_Game.cs プロジェクト: LeonardRumeghea/Archero
        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();
                                }
                            }
                        }
                    }
                }
            }
        }