Esempio n. 1
0
        /// <summary>
        /// Updates all objects in the world, performs collision between them,
        /// and handles the time limit with scoring.
        /// </summary>
        public void Update(GameTime gameTime, InputState input)
        {
            if (this._player != null)
            {
                // Pause while the player is dead or time is expired.
                if (!this._player.IsAlive || (this._player.TimeToLive == TimeSpan.Zero))
                {
                    // Remove the player from the level
                    this._player = null;
                }
                else
                {
                    // Check for collisions
                    CollisionManager.Update((float)gameTime.ElapsedGameTime.TotalSeconds);

                    // Perform player and sprite updates
                    this._player.Update(gameTime, input);
                    this._sprites.ForEach((sprite) => sprite.Update(gameTime, input));
                }
            }
        }
Esempio n. 2
0
            /// <summary>
            /// Initializes a new instance of the <see cref="CollisionManagerScope" /> class.
            /// </summary>
            /// <param name="bounds">The bounds.</param>
            /// <param name="collisionLayer">The collision layer.</param>
            public CollisionManagerScope(Rectangle?bounds = null, Layer collisionLayer = null)
            {
                this._previousCollisionManager = CollisionManager._collisionManager;

                CollisionManager._collisionManager = bounds.HasValue ? new CollisionManager(bounds.Value, collisionLayer) : null;
            }