Esempio n. 1
0
        private void UpdateBullets(List <Weapon> bullets, List <Obstacle> obstacles, PointerSurvivalModel m)
        {
            if (bullets.Count > 0)
            {
                bool isHit = false;
                foreach (Weapon bullet in bullets)
                {
                    bullet.BulletMove();

                    foreach (Obstacle o in obstacles)
                    {
                        if (o.isHit(bullet))
                        {
                            m.cal.storevalue(o.Number);

                            if (m.cal.checkans(int.Parse(answerlbl.Text)))
                            {
                                answerlbl.Text = "" + Obstacle.random.Next(1, 20);
                            }

                            num1lbl.Text      = "" + m.cal.getNum1;
                            num2lbl.Text      = "" + m.cal.getNum2;
                            operationlbl.Text = m.cal.getSymbol;
                            scorelbl.Text     = "" + m.cal.getScore;

                            o.obj.Dispose();
                            bullet.obj.Dispose();

                            this.Controls.Remove(o.obj);
                            this.Controls.Remove(bullet.obj);

                            m.Remove(o);
                            m.Remove(bullet);
                            isHit = true;
                            break;
                        }
                    }
                    if (isHit)
                    {
                        break;
                    }
                }
            }
        }
        private void UpdateBullets(List<Weapon> bullets,List<Obstacle> obstacles, PointerSurvivalModel m)
        {
            if (bullets.Count > 0)
            {
                bool isHit = false;
                foreach (Weapon bullet in bullets)
                {
                    bullet.BulletMove();

                    foreach (Obstacle o in obstacles)
                    {
                        if (o.isHit(bullet))
                        {
                            m.cal.storevalue(o.Number);

                            if (m.cal.checkans(int.Parse(answerlbl.Text)))
                            {
                                answerlbl.Text = "" + Obstacle.random.Next(1,20);
                            }

                            num1lbl.Text = "" + m.cal.getNum1;
                            num2lbl.Text = "" + m.cal.getNum2;
                            operationlbl.Text = m.cal.getSymbol;
                            scorelbl.Text = "" + m.cal.getScore;

                            o.obj.Dispose();
                            bullet.obj.Dispose();

                            this.Controls.Remove(o.obj);
                            this.Controls.Remove(bullet.obj);

                            m.Remove(o);
                            m.Remove(bullet);
                            isHit = true;
                            break;
                        }

                    }
                    if(isHit)
                        break;

                }
            }
        }