Exemple #1
0
        /// <summary>
        /// Update for the Air class that is called once per frame.
        /// </summary>
        /// <param name="gameTime">Snapshot of the game timing state.</param>
        /// <param name="shoes">A reference to the Shoes.</param>
        /// <param name="guy">A reference to the Guy.</param>
        public void Update(GameTime gameTime, ref Shoes shoes, ref Guy guy)
        {
            Animate(gameTime);

            foreach (Air air in Air.allAirs)
            {
                // Shoes Collision
                if (air.RotatedRect.Intersects(new RotatedRectangle(shoes.PositionRect, 0.0f)) && !shoes.airsShoesHasCollidedWith.Contains(air))
                {
                    shoes.airsShoesHasCollidedWith.Add(air);
                    shoes.setVelocityUponAirCollision(air.airCannonRepresentation);
                }

                // Guy Collision
                if (air.RotatedRect.Intersects(new RotatedRectangle(guy.PositionRect, 0.0f)) && !guy.airsGuyHasCollidedWith.Contains(air))
                {
                    guy.airsGuyHasCollidedWith.Add(air);
                    guy.setVelocityUponAirCollision(air.airCannonRepresentation);
                }
            }

            shoes.clearAirsThatShoesCollidedWithIfPossible();
        }