MageDefenderDeluxe.GameObjects.SpellHandler.Update C# (CSharp) Method

Update() public method

Allows the game component to update itself.
public Update ( GameTime gameTime, float thumbSticksRightX ) : void
gameTime Microsoft.Xna.Framework.GameTime Provides a snapshot of timing values.
thumbSticksRightX float
return void
        public void Update(GameTime gameTime, float thumbSticksRightX)
        {
            engine.Update();
            ICamera camera = (ICamera)Game.Services.GetService(typeof(ICamera));

            int itemsToDelete = 0;
            foreach (Spell s in spells)
            {
                if (s.Active)
                {
                    s.Update(camera.ViewMatrix, camera.ProjectionMatrix, gameTime, thumbSticksRightX);
                }
                else
                {
                    itemsToDelete++;
                }
            }

            while (itemsToDelete > 0)
            {
                int index = -1;
                foreach (Spell s in spells)
                {
                    index++;
                    if (!s.Active)
                    {
                        for (int i = 0; i < 10; i++)
                        {
                            collideCue = soundBank.GetCue("sizzle");
                            if (!collideCue.IsPlaying)
                            {
                                collideCue.Play();
                            }
                            killEnemyParticles.AddParticle(new Vector3(s.PositionX * 0.008f, s.PositionY * 0.008f, s.PositionZ * 0.008f), Vector3.Zero);
                        }
                        break;
                    }
                }
                spells.RemoveRange(index, 1);
                itemsToDelete--;
            }

            killEnemyParticles.SetCamera(camera.ViewMatrix, camera.ProjectionMatrix);
            fireBallParticles.SetCamera(camera.ViewMatrix, camera.ProjectionMatrix);
            slowEnemyParticles.SetCamera(camera.ViewMatrix, camera.ProjectionMatrix);
            poisonEnemyParticles.SetCamera(camera.ViewMatrix, camera.ProjectionMatrix);
            magicMissilePartilces.SetCamera(camera.ViewMatrix, camera.ProjectionMatrix);

            foreach (Spell s in SpellList)
            {
                if (s.Type == GameObjects.SpellHandler.Spells.Fireball)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        fireBallParticles.AddParticle(new Vector3(s.PositionX * 0.008f, s.PositionY * 0.008f, s.PositionZ * 0.008f), Vector3.Zero);
                    }
                }

                if (s.Type == GameObjects.SpellHandler.Spells.Slowball)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        slowEnemyParticles.AddParticle(new Vector3(s.PositionX * 0.008f, s.PositionY * 0.008f, s.PositionZ * 0.008f), Vector3.Zero);
                    }
                }

                if (s.Type == GameObjects.SpellHandler.Spells.PoisonBall)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        poisonEnemyParticles.AddParticle(new Vector3(s.PositionX * 0.008f, s.PositionY * 0.008f, s.PositionZ * 0.008f), Vector3.Zero);
                    }
                }

                if (s.Type == GameObjects.SpellHandler.Spells.MagicMissile)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        magicMissilePartilces.AddParticle(new Vector3(s.PositionX * 0.008f, s.PositionY * 0.008f, s.PositionZ * 0.008f), Vector3.Zero);
                    }
                }

                if (s.Type == GameObjects.SpellHandler.Spells.EnergyBall)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        magicMissilePartilces.AddParticle(new Vector3(s.PositionX * 0.008f, s.PositionY * 0.008f, s.PositionZ * 0.008f), Vector3.Zero);
                        fireBallParticles.AddParticle(new Vector3(s.PositionX * 0.008f, s.PositionY * 0.008f, s.PositionZ * 0.008f), Vector3.Zero);
                    }
                }
            }

            killEnemyParticles.Update(gameTime);
            poisonEnemyParticles.Update(gameTime);
            slowEnemyParticles.Update(gameTime);
            fireBallParticles.Update(gameTime);
            magicMissilePartilces.Update(gameTime);

            base.Update(gameTime);
        }