Пример #1
0
        public static void FiresUpdate(ref List <Fire> bullets, List <Enemies> versus)// collision between plane fires and all enemies
        {
            for (int x = 0; x < bullets.Count; ++x)
            {
                Fire fire = bullets[x];       // plane's fires

                foreach (Enemies q in versus) // enemies
                {
                    if (Events.pixelCollesion(q.texturesCollection[q.StandardImgFrame], fire.texturesCollection[fire.StandardImgFrame], new Vector2((float)q.cordx, (float)q.cordy), new Vector2((float)fire.cordx, (float)fire.cordy)))
                    {
                        fire.Exist = false;

                        Events.score++;
                        q.enemhealth -= 30;

                        if (q.enemhealth <= 0)
                        {
                            q.Exist       = false;
                            Events.score += 2;
                        }
                    }
                }

                if (fire.OutOfBorders(fire.width, fire.height) || !fire.Exist) // delete fire
                {
                    bullets.Remove(fire);
                    fire.Exist = false;
                    x--;
                }
                else // update
                {
                    fire.Update();
                }
            }
        }
Пример #2
0
        protected override void Update(GameTime gameTime)
        {
            elapsed         = (float)gameTime.ElapsedGameTime.TotalSeconds;
            LevelShowTimer -= elapsed;
            ///////////////////////

            LEVELS_ORGANIZATION_CREATION();

            Time = (float)gameTime.ElapsedGameTime.TotalSeconds;
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }
            KeyboardState keyboard = Keyboard.GetState();

            if (keyboard.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            LEVELS_ORGANIZATION_UPDATE();

            movingBackGround.Update();
            Airplane.Update();
            fire.Update();
            //   enm.Update(0.06f , 0.04f);
            Events.update();
            // TODO: Add your update logic here

            base.Update(gameTime);
        }
Пример #3
0
        public static void FiresUpdate(ref List <Fire> bullets, MainPlane versus)// collision between all anemies fires and Plane
        {
            for (int x = 0; x < bullets.Count; ++x)
            {
                Fire fire = bullets[x];

                if (Events.pixelCollesion(versus.texturesCollection[versus.StandardImgFrame], fire.texturesCollection[fire.StandardImgFrame], new Vector2((float)versus.cordx, (float)versus.cordy), new Vector2((float)fire.cordx, (float)fire.cordy)))
                {
                    fire.Exist     = false;
                    Events.health -= 20;
                }

                if (fire.OutOfBorders(fire.width, fire.height) || !fire.Exist) // delete
                {
                    bullets.Remove(fire);
                    fire.Exist = false;
                    x--;
                }
                else // update
                {
                    fire.Update();
                }
            }
        }