Beispiel #1
0
        private void Bombs(float timer)
        {
            space += timer;

            foreach (BombView bomb in bombs)
            {
                m_BombModel.Update();

                if (m_View.playerRectangle().Intersects(bomb.BombRectangle()))
                {
                    m_BombEffect.Play();
                    isHit = true;
                    model.getPlayerDefaultPosition();
                    model.GhostDefaultPosition();
                    model.loseALife();
                }
            }

            if (isHit)
            {
                bombs.Clear();
                isHit = false;
            }


            // the space between the boms is larger or equals 5 , make it zero.
            if (space >= 5)
            {
                space = 0;

                // add bombs position
                m_BombModel = new BombModel(new Vector2(GraphicsDevice.Viewport.Width / 1.5f, GraphicsDevice.Viewport.Height / 6), CurrentLevel);
                bombs.Add(new BombView(Content, m_BombModel));


                // Remove the bomb if it is not visible any more.
                for (int i = 0; i < bombs.Count; i++)
                {
                    if (m_BombModel.isHidden)
                    {
                        bombs.RemoveAt(i);
                        i -= 1;
                    }
                }
            }
        }