ScrollingShooter.GameObjectManager.CreateExplosion C# (CSharp) Method

CreateExplosion() public method

Factory method for creating an explosion
public CreateExplosion ( uint colliderID ) : ScrollingShooter.Explosion
colliderID uint The source of the explosion
return ScrollingShooter.Explosion
        public Explosion CreateExplosion(uint colliderID)
        {
            Explosion ex;
            uint id = NextID();
            Vector2 pos = new Vector2(GetObject(colliderID).Bounds.X, GetObject(colliderID).Bounds.Y);
            ex = new Explosion(id, pos, content);
            QueueGameObjectForCreation(ex);
            return ex;
        }

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::CreateExplosion