Esempio n. 1
0
        public void UpdateProjectiles_TouchTop()
        {
            //arrange
            int          laserSpeed  = -5;
            int          laserWidth  = 1;
            int          laserHeight = 1;
            int          alienCount  = 5;
            LaserFactory laser       = new LaserFactory(laserSpeed, laserWidth, laserHeight, alienCount);

            //act
            int xLaser = laser.Laser.BoundingBox.X;
            int yLaser = laser.Laser.BoundingBox.Y;

            laser.UpdateProjectiles();

            int xLaser1 = laser.Laser.BoundingBox.X;
            int yLaser1 = laser.Laser.BoundingBox.Y;

            //assert

            Assert.AreEqual(0, xLaser); //expected, actual
            Assert.AreEqual(0, yLaser);


            Assert.AreEqual(0, xLaser1); //expected, actual
            Assert.AreEqual(0, yLaser1);
        }
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (player.Alive)
            {
                laserFactory.UpdateProjectiles();
                bombFactory.UpdateProjectiles();
                alienSquad.Update();
            }

            base.Update(gameTime);
        }
Esempio n. 3
0
        public void UpdateProjectiles_TouchMothership()
        {
            //arrange
            int          laserSpeed  = -5;
            int          laserWidth  = 1;
            int          laserHeight = 1;
            int          alienCount  = 5;
            LaserFactory laser       = new LaserFactory(laserSpeed, laserWidth, laserHeight, alienCount);

            int        mothershipW = 10;
            int        screenW     = 20;
            int        speed       = 5; //should end up at 0
            Mothership ms          = new Mothership(screenW, mothershipW, mothershipHeight, speed, mothershipPoints, timerIntervalMothership, mothershipSpacerFromTop);

            //act

            int xMothership = ms.BoundingBox.X;
            int yMothership = ms.BoundingBox.Y;
            int xLaser      = laser.Laser.BoundingBox.X;
            int yLaser      = laser.Laser.BoundingBox.Y;

            laser.UpdateProjectiles();

            int xMothership1 = ms.BoundingBox.X;
            int yMothership1 = ms.BoundingBox.Y;
            int xLaser1      = laser.Laser.BoundingBox.X;
            int yLaser1      = laser.Laser.BoundingBox.Y;

            //assert
            Assert.AreEqual(0, xMothership); //expected, actual
            Assert.AreEqual(0, yMothership);
            Assert.AreEqual(0, xLaser);      //expected, actual
            Assert.AreEqual(0, yLaser);

            Assert.AreEqual(0, xMothership1); //expected, actual
            Assert.AreEqual(0, yMothership1);
            Assert.AreEqual(0, xLaser1);      //expected, actual
            Assert.AreEqual(0, yLaser1);
        }
Esempio n. 4
0
        public void UpdateProjectiles_TouchBunkers()
        {
            //arrange
            int          laserSpeed  = -5;
            int          laserWidth  = 1;
            int          laserHeight = 1;
            int          alienCount  = 5;
            LaserFactory laser       = new LaserFactory(laserSpeed, laserWidth, laserHeight, alienCount);

            int     numBunkers   = 1;
            int     screenWidth  = 100;
            int     screenHeight = 100;
            int     bunkerWidth  = 5;
            int     bunkerHeight = 5;
            int     bunkerHealth = 3;
            int     playerHeight = 5;
            int     spaceBetweenBunkerAndPlayer = 1;
            Bunkers bunkers = new Bunkers(numBunkers, screenWidth, screenHeight, bunkerWidth, bunkerHeight, bunkerHealth, playerHeight, spaceBetweenBunkerAndPlayer);

            //act
            int xLaser = laser.Laser.BoundingBox.X;
            int yLaser = laser.Laser.BoundingBox.Y;

            laser.UpdateProjectiles();

            int xLaser1 = laser.Laser.BoundingBox.X;
            int yLaser1 = laser.Laser.BoundingBox.Y;

            //assert

            Assert.AreEqual(0, xLaser); //expected, actual
            Assert.AreEqual(0, yLaser);


            Assert.AreEqual(0, xLaser1); //expected, actual
            Assert.AreEqual(0, yLaser1);
        }