ScrollingShooter.GameObjectManager.DestroyObject C# (CSharp) Method

DestroyObject() public method

Removes the indicated game object from the game
public DestroyObject ( uint id ) : ScrollingShooter.GameObject
id uint The game object's ID
return ScrollingShooter.GameObject
        public GameObject DestroyObject(uint id)
        {
            GameObject go = gameObjects[id];
            destroyedGameObjects.Enqueue(go);
            return go;
        }

Usage Example

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            // TODO: Add your update logic here
            float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            LevelManager.Update(elapsedTime);

            GameObjectManager.Update(elapsedTime);

            // Process collisions
            foreach (CollisionPair pair in GameObjectManager.Collisions)
            {
                // Player collisions
                if (pair.A == Player.ID || pair.B == Player.ID)
                {
                    uint       colliderID = (pair.A == Player.ID) ? pair.B : pair.A;
                    GameObject collider   = GameObjectManager.GetObject(colliderID);

                    // Process powerup collisions
                    Powerup powerup = collider as Powerup;
                    if (powerup != null)
                    {
                        Player.ApplyPowerup(powerup.Type);
                        GameObjectManager.DestroyObject(colliderID);
                    }

                    //NOTE: Apply to more than the kamikaze enemy?
                    // Process kamakaze collisions
                    Enemy enemy = collider as Enemy;
                    if (enemy != null && enemy.GetType() == typeof(Kamikaze))
                    {
                        //Player take damage
                        GameObjectManager.DestroyObject(colliderID);
                        GameObjectManager.CreateExplosion(colliderID);
                    }
                }
            }

            base.Update(gameTime);
        }
All Usage Examples Of ScrollingShooter.GameObjectManager::DestroyObject