Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. public override void Update(GameTime gameTime)
  2.       {
  3.          if (IsActive)
  4.          {
  5.             attackTimer -= (float)gameTime.ElapsedGameTime.TotalSeconds;
  6.  
  7.             if (attackTimer <= 0)
  8.             {
  9.                bombData.relativeTranslation = this.AbsolutePosition() + new Vector3(0, 50, 0);
  10.                if (staticBombPool.Count < 1)
  11.                {
  12.                   staticBombPool.Enqueue(new Bomb(Vector3.One, null, bombData));
  13.                }
  14.                else
  15.                {
  16.                   Bomb tempBomb = staticBombPool.Dequeue();
  17.                   tempBomb.Data = bombData;
  18.                   tempBomb.LifeTimer = 0.0f;
  19.                   tempBomb.DeserializeData();
  20.                   bombs.Add(tempBomb);
  21.                }
  22.                attackTimer = attackFrequencyBase;
  23.             }
  24.  
  25.             foreach (Bomb bomb in bombs)
  26.             {
  27.                bomb.Update(gameTime);
  28.             }
  29.  
  30.             for (int i = 0; i < bombs.Count; i++)
  31.             {
  32.                if (bombs[i].LifeTimer > bombs[i].Lifespan)
  33.                {
  34.                   Bomb bomb = bombs[i];
  35.                   bombs.RemoveAt(i);
  36.                   staticBombPool.Enqueue(bomb);
  37.                   i--;
  38.                }
  39.             }
  40.          }
  41.  
  42.          base.Update(gameTime);
  43.       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement