示例#1
0
        public void TestEnemyOnLeftOfBlockCollisionDetection()
        {
            Goomba     enemy = new Goomba(new Vector2(100, 100));
            FloorBlock block = new FloorBlock(new Vector2(120, 100));

            Rectangle enemyRect = enemy.GetRectangle();
            Rectangle blockRect = block.GetRectangle();

            GeneralCollisionDetector generalDetector = new GeneralCollisionDetector();

            Game1.Side collisionType = generalDetector.DetermineCollision(enemyRect, blockRect);

            Assert.AreEqual(collisionType, Game1.Side.Right);
        }
示例#2
0
        public void TestMarioOnBottomOfEnemyCollisionDetector()
        {
            Mario  mario = new Mario(new Vector2(100, 115));
            Goomba enemy = new Goomba(new Vector2(100, 100));

            Rectangle marioRect = mario.GetRectangle();
            Rectangle enemyRect = enemy.GetRectangle();

            GeneralCollisionDetector generalDetector = new GeneralCollisionDetector();

            Game1.Side collisionType = generalDetector.DetermineCollision(marioRect, enemyRect);
            Game1.Side expectedType  = Game1.Side.Top;
            Assert.AreEqual(expectedType, collisionType);
        }
示例#3
0
        public void TestMarioOnBottomOfEnemyCollisionHandling()
        {
            Mario  mario = new Mario(new Vector2(100, 115));
            Goomba enemy = new Goomba(new Vector2(100, 100));

            Rectangle marioRect = mario.GetRectangle();
            Rectangle enemyRect = enemy.GetRectangle();

            Game1.Side collisionType = Game1.Side.Top;
            MarioEnemyCollisionHandler.HandleCollision(mario, enemy, collisionType);
            bool actualValue   = mario.IsDying();
            bool expectedValue = true;

            Assert.AreEqual(expectedValue, actualValue);
        }
示例#4
0
        public void TestEnemyOnRightOfBlockCollisionHandling()
        {
            IEnemy     enemy       = new Goomba(new Vector2(110, 100));
            Goomba     staticEnemy = new Goomba(new Vector2(100, 100));
            FloorBlock block       = new FloorBlock(new Vector2(100, 100));

            Rectangle enemyRect = enemy.GetRectangle();
            Rectangle blockRect = block.GetRectangle();

            Game1.Side collisionType = Game1.Side.Left;
            EnemyBlockCollisionHandler.HandleCollision(enemy, block, collisionType);

            IEnemyState enemyState    = enemy.GetState();
            IEnemyState expectedState = new GoombaLeftMovingState(staticEnemy);

            Assert.AreEqual(enemyState.ToString(), expectedState.ToString());
        }