Exemplo n.º 1
0
 // Update
 public void Update(GameTime gameTime)
 {
     // Update PlayerShotManager.
     PlayerShotManager.Update(gameTime);
     // Make shotTimer count upwards in milliseconds (allows shooting) if player ins't dead.
     if (!Destroyed)
     {
         shotTimer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
     }
     // Update arms.
     Arms(gameTime);
 }
Exemplo n.º 2
0
        // Update
        public void Update(GameTime gameTime)
        {
            EnemyShotManager.Update(gameTime);

            for (int i = Enemies.Count - 1; i >= 0; i--)
            {
                Enemies[i].Update(gameTime);
                if (Enemies[i].IsActive() == false)
                {
                    Enemies.RemoveAt(i);
                }

                else
                {
                    // Make a random chance that a shot is fired.
                    if ((float)rand.Next(0, 1000) / 10 <= shipShotChance)
                    {
                        // Location from which shot should be fired.
                        Vector2 fireLoc = Enemies[i].EnemySprite.Position;
                        fireLoc += Enemies[i].GunOffset;

                        //  Direction in which shot whould be fired.
                        Vector2 shotDirection = playerManager.Center - fireLoc;
                        shotDirection.Normalize();

                        // Fire shot.
                        EnemyShotManager.FireShot(fireLoc, shotDirection, false);
                        // Play firing sound.
                        firingSound.Play();
                    }
                }
            }

            if (Active)
            {
                updateWaveSpawns(gameTime);
            }
        }