コード例 #1
0
        public bool checkZombieCollisions(List <Zombie> zombies, BMFZ bmfz)
        {
            bool dead = false;

            foreach (Zombie z in zombies)
            {
                if (!z.isAlive)
                {
                    break;
                }
                else if (BoundingBox.Intersects(z.CollisionBox) || BoundingBox.Intersects(bmfz.HitBox))
                {
                    dead = true;
                }
            }


            return(dead);
        }
コード例 #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        /// All loadings should be done in LoadContent -tai
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.

            spriteBatch = new SpriteBatch(GraphicsDevice);
            bgTexture   = Content.Load <Texture2D>("background");
            line        = Content.Load <Texture2D>("markerline");
            player1     = new Player(this);
            bmfz        = new BMFZ(this);
            font        = Content.Load <SpriteFont>("main_font");
            zombieKill  = Content.Load <SoundEffect>("zdeath4");

            death = Content.Load <SoundEffect>("death3");

            SoundPlayer player = new SoundPlayer("Content/Zander Noriega - Abelian.wav");

            player.PlayLooping();
            MediaPlayer.Volume = 1.0f;
            MediaPlayer.Play(song);


            //block1 = new block(this);
            //block1.LoadContent();
            //block1.position = new Vector2(470, 600);//position.y = 660, the character doesn't get underneath. I need to adjust the ratio in the class.
            //block2 = new block(this);
            //block2.LoadContent();
            //block2.position = new Vector2(300, 650);
            //block3 = new block(this);
            //block3.LoadContent();
            // block3.position = new Vector2(250, 650);

            //set up block array, load all block content

            //for (int i = 0; i < rnd.Next(6,15); i++)
            //{
            //    block b = new block(this);
            //    b.LoadContent();
            //    blocks.Add(b);
            //}

            ////for loop trial for "randomly" placing tiles


            //foreach(block b in blocks){
            //    x1 = rnd.Next(100, 700);
            //    y1 = 600;
            //    b.position = new Vector2(x1, y1);

            //}

            midLevelGenerator();
            topLevelGenerator();
            lowLevelGenerator();
            offscreenZombieGenerator();

            //refinement of block placement
            //for (int i = 1; i < blocks.Count; i++)
            //{
            //    if (blocks[i - 1].position.X >= (blocks[i].position.X + 50))
            //    {
            //        blocks[i].position.X = blocks[i-1].position.X + 100;
            //    }
            //    if (blocks[i - 1].position.Y >= (blocks[i].position.Y - 25))
            //    {
            //        blocks[i].position.Y = blocks[i-1].position.Y - 75;
            //    }
            //}
            //offscreenZombieGenerator();



            player1.LoadContent();
            player1.position = new Vector2(300, 700);
            bmfz.LoadContent();
            bmfz.position = new Vector2(50, 700);

            // TODO: use this.Content to load your game content here
        }