private void UpdateBarrier(float delta, Barrier barrier)
 {
     // Check if any of the enemies are colliding with the barrier.
     foreach (var enemy in enemies.Where(enemy => enemy.Alive))
     {
         if (barrier.Bounds.Intersects(enemy.Bounds))
             barrier.Health = 0;
     }
 }
Beispiel #2
0
 private void handleBulletHitsBarrier(Bullet i_Bullet, Barrier i_Barrier)
 {
     i_Barrier.ReceiveBulletDamage(i_Bullet);
     r_KillQueue.Enqueue(i_Bullet);
 }
        public override void Initialize()
        {
            Texture2D barrierTexture = Game.Content.Load<Texture2D>(@"Sprites\Barrier_44x32");

            if (m_Barriers == null)
            {
                m_Barriers = new Barrier[k_AmountOfBarriers];
            }

            int playerHeight = 32;
            int YLocation = Game.GraphicsDevice.Viewport.Height - (2 * playerHeight) - (2 * barrierTexture.Height);
            int widthOfTheWholeGroup = ((k_AmountOfBarriers * 2) - 1) * barrierTexture.Width;
            int XLocationForLeftBarrier = (Game.GraphicsDevice.Viewport.Width / 2) - (widthOfTheWholeGroup / 2);

            for (int i = 0; i < m_Barriers.Length; i++)
            {
                m_Barriers[i] = new Barrier(m_Game);
                m_Barriers[i].Initialize();
                m_Barriers[i].Position = new Vector2(XLocationForLeftBarrier + (i * barrierTexture.Width * 2), YLocation);
                m_Barriers[i].Velocity = m_Velocity;
            }

            m_IsInitialized = true;
        }
Beispiel #4
0
 private void handleInvaderCollidedWithBarrier(Invader i_Invader, Barrier i_Barrier)
 {
     i_Barrier.ErasePixelsThatIntersectWith(i_Invader);
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new <see cref="BarrierHitResult"/>.
 /// </summary>
 /// <param name="barrier">The <see cref="SpaceInvaders.Barrier"/> that was hit.</param>
 /// <param name="tile">The <see cref="BarrierTile"/> that was hit in the specified <see cref="SpaceInvaders.Barrier"/>.</param>
 public BarrierHitResult(Barrier barrier, BarrierTile tile)
 {
     Barrier = barrier;
     Tile    = tile;
 }