public void FireMarioRedMushroomRightSideCollisionTest() { MarioInstance testMario = new MarioInstance(game); MarioInstance expectedMario = new MarioInstance(game); expectedMario.Flower(); testMario.Flower(); RedMushroom testRedMushroom = new RedMushroom(game); RedMushroom expectedRedMushroom = new RedMushroom(game); expectedRedMushroom.Disappear(); ICollisionSide side = new RightSideCollision(); CollisionData collision = new CollisionData(testMario, testRedMushroom, side); MarioItemCollisionHandler collisionHandler = new MarioItemCollisionHandler(collision); collisionHandler.HandleCollision(); bool testState = testMario.MarioState is FireRightIdleState; bool expectedState = expectedMario.MarioState is FireRightIdleState; Vector2 testLocation = testMario.VectorCoordinates; Vector2 expectedLocation = expectedMario.VectorCoordinates; Assert.AreEqual(testState, expectedState); Assert.AreEqual(testLocation, expectedLocation); }
public void SmallMarioStarRightSideCollisionTest() { WorldManager.LoadListFromFile("World1-1", game); MarioInstance testMario = new MarioInstance(game); MarioInstance expectedMario = new MarioInstance(game); expectedMario.Star(); Star testStar = new Star(game); Star expectedStar = new Star(game); expectedStar.Disappear(); ICollisionSide side = new RightSideCollision(); CollisionData collision = new CollisionData(testMario, testStar, side); MarioItemCollisionHandler collisionHandler = new MarioItemCollisionHandler(collision); collisionHandler.HandleCollision(); bool testState = testMario.MarioState is SmallRightIdleState; bool expectedState = expectedMario.MarioState is SmallRightIdleState; Vector2 testLocation = testMario.VectorCoordinates; Vector2 expectedLocation = expectedMario.VectorCoordinates; Assert.AreEqual(testState, expectedState); Assert.AreEqual(testLocation, expectedLocation); }
public void BigMarioGreenMushroomLeftSideCollisionTest() { MarioInstance testMario = new MarioInstance(game); MarioInstance expectedMario = new MarioInstance(game); testMario.Mushroom(); expectedMario.Mushroom(); GreenMushroom testGreenMushroom = new GreenMushroom(game); GreenMushroom expectedGreenMushroom = new GreenMushroom(game); expectedGreenMushroom.Disappear(); ICollisionSide side = new LeftSideCollision(); CollisionData collision = new CollisionData(testMario, testGreenMushroom, side); MarioItemCollisionHandler collisionHandler = new MarioItemCollisionHandler(collision); collisionHandler.HandleCollision(); bool testState = testMario.MarioState is NormalRightIdleState; bool expectedState = expectedMario.MarioState is NormalRightIdleState; Vector2 testLocation = testMario.VectorCoordinates; Vector2 expectedLocation = expectedMario.VectorCoordinates; Assert.AreEqual(testState, expectedState); Assert.AreEqual(testLocation, expectedLocation); }
public void SmallMarioCoinTopSideCollisionTest() { MarioInstance testMario = new MarioInstance(game); MarioInstance expectedMario = new MarioInstance(game); Coin testCoin = new Coin(game); Coin expectedCoin = new Coin(game); expectedCoin.Disappear(); ICollisionSide side = new TopSideCollision(); CollisionData collision = new CollisionData(testMario, testCoin, side); MarioItemCollisionHandler collisionHandler = new MarioItemCollisionHandler(collision); collisionHandler.HandleCollision(); bool testState = testMario.MarioState is SmallRightIdleState; bool expectedState = expectedMario.MarioState is SmallRightIdleState; Vector2 testLocation = testMario.VectorCoordinates; Vector2 expectedLocation = expectedMario.VectorCoordinates; Assert.AreEqual(testState, expectedState); Assert.AreEqual(testLocation, expectedLocation); }
public void SmallMarioFlowerLeftSideCollisionTest() { MarioInstance testMario = new MarioInstance(game); MarioInstance expectedMario = new MarioInstance(game); expectedMario.Flower(); Flower testFlower = new Flower(game); Flower expectedFlower = new Flower(game); expectedFlower.Disappear(); ICollisionSide side = new LeftSideCollision(); CollisionData collision = new CollisionData(testMario, testFlower, side); MarioItemCollisionHandler collisionHandler = new MarioItemCollisionHandler(collision); collisionHandler.HandleCollision(); bool testState = testMario.MarioState is FireRightIdleState; bool expectedState = expectedMario.MarioState is FireRightIdleState; Vector2 testLocation = testMario.VectorCoordinates; Vector2 expectedLocation = expectedMario.VectorCoordinates; Assert.AreEqual(testState, expectedState); Assert.AreEqual(testLocation, expectedLocation); }
public static void HandleCollision(CollisionData collision, IGameState gameState){ if ((collision.GameObjectA is IMario && collision.GameObjectB is IEnemy) || (collision.GameObjectA is IEnemy && collision.GameObjectB is IMario)) { MarioEnemyCollisionHandler collisionHandler = new MarioEnemyCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IMario && collision.GameObjectB is IBlock) || (collision.GameObjectA is IBlock && collision.GameObjectB is IMario)) { MarioBlockCollisionHandler collisionHandler = new MarioBlockCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IMario && collision.GameObjectB is IItem) || (collision.GameObjectA is IItem && collision.GameObjectB is IMario)) { MarioItemCollisionHandler collisionHandler = new MarioItemCollisionHandler(collision, gameState); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IMario && collision.GameObjectB is IPipe) || (collision.GameObjectA is IPipe && collision.GameObjectB is IMario)) { MarioPipeCollisionHandler collisionHandler = new MarioPipeCollisionHandler(collision, gameState); collisionHandler.HandleCollision(); } else if (collision.GameObjectA is IEnemy && collision.GameObjectB is IEnemy) { EnemyEnemyCollisionHandler collisionHandler = new EnemyEnemyCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IEnemy && collision.GameObjectB is IBlock) || (collision.GameObjectA is IBlock && collision.GameObjectB is IEnemy)) { EnemyBlockCollisionHandler collisionHandler = new EnemyBlockCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IEnemy && collision.GameObjectB is IPipe) || (collision.GameObjectA is IPipe && collision.GameObjectB is IEnemy)) { EnemyPipeCollisionHandler collisionHandler = new EnemyPipeCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IEnemy && collision.GameObjectB is IProjectile) || (collision.GameObjectA is IProjectile && collision.GameObjectB is IEnemy)) { EnemyFireballCollisionHandler collisionHandler = new EnemyFireballCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IItem && collision.GameObjectB is IBlock) || (collision.GameObjectA is IBlock && collision.GameObjectB is IItem)) { ItemBlockCollisionHandler collisionHandler = new ItemBlockCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IItem && collision.GameObjectB is IPipe) || (collision.GameObjectA is IPipe && collision.GameObjectB is IItem)) { ItemPipeCollisionHandler collisionHandler = new ItemPipeCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IBlock && collision.GameObjectB is IProjectile) || (collision.GameObjectA is IProjectile && collision.GameObjectB is IBlock)) { BlockFireballCollisionHandler collisionHandler = new BlockFireballCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IPipe && collision.GameObjectB is IProjectile) || (collision.GameObjectA is IProjectile && collision.GameObjectB is IPipe)) { PipeFireballCollisionHandler collisionHandler = new PipeFireballCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IMario && collision.GameObjectB is IFlagPole) || (collision.GameObjectA is IFlagPole && collision.GameObjectB is IMario)) { MarioFlagPoleCollisionHandler collisionHandler = new MarioFlagPoleCollisionHandler(collision, gameState); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IBuckeyePlayer && collision.GameObjectB is IBuckeyeTile) || (collision.GameObjectA is IBuckeyeTile && collision.GameObjectB is IBuckeyePlayer)) { BuckeyeTileCollisionHandler collisionHandler = new BuckeyeTileCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IBuckeyePlayer && collision.GameObjectB is IProjectile) || (collision.GameObjectA is IProjectile && collision.GameObjectB is IBuckeyePlayer)) { BuckeyeProjectileCollisionHandler collisionHandler = new BuckeyeProjectileCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IWolverine && collision.GameObjectB is IBuckeyeTile) || (collision.GameObjectA is IBuckeyeTile && collision.GameObjectB is IWolverine)) { WolverineTileCollisionHandler collisionHandler = new WolverineTileCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IWolverine && collision.GameObjectB is IPipe) || (collision.GameObjectA is IPipe && collision.GameObjectB is IWolverine)) { WolverinePipeCollisionHandler collisionHandler = new WolverinePipeCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IWolverine && collision.GameObjectB is IProjectile) || (collision.GameObjectA is IProjectile && collision.GameObjectB is IWolverine)) { WolverineProjectileCollisionHandler collisionHandler = new WolverineProjectileCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IBuckeyePlayer && collision.GameObjectB is IWolverine) || (collision.GameObjectA is IWolverine && collision.GameObjectB is IBuckeyePlayer)) { BuckeyeWolverineCollisionHandler collisionHandler = new BuckeyeWolverineCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IBuckeyePlayer && collision.GameObjectB is IPipe) || (collision.GameObjectA is IPipe && collision.GameObjectB is IBuckeyePlayer)) { BuckeyePipeCollisionHandler collisionHandler = new BuckeyePipeCollisionHandler(collision, gameState); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IProjectile && collision.GameObjectB is IProjectile) || (collision.GameObjectA is IProjectile && collision.GameObjectB is IProjectile)) { ProjectileProjectileCollisionHandler collisionHandler = new ProjectileProjectileCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IProjectile && collision.GameObjectB is IBuckeyeTile) || (collision.GameObjectA is IBuckeyeTile && collision.GameObjectB is IProjectile)) { ProjectileTileCollisionHandler collisionHandler = new ProjectileTileCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IEnemy && collision.GameObjectB is Elevator) || (collision.GameObjectA is Elevator && collision.GameObjectB is IEnemy)) { EnemyElevatorCollisionHandler collisionHandler = new EnemyElevatorCollisionHandler(collision, gameState); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IEnemy && collision.GameObjectB is Endblock) || (collision.GameObjectA is Endblock && collision.GameObjectB is IEnemy)) { EnemyEndblockCollisionHandler collisionHandler = new EnemyEndblockCollisionHandler(gameState); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IItem && collision.GameObjectB is IPaddleBall) || (collision.GameObjectA is IPaddleBall && collision.GameObjectB is IItem)) { PaddleBallItemCollisionHandler collisionHandler = new PaddleBallItemCollisionHandler(collision, gameState); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IBlock && collision.GameObjectB is IPaddle) || (collision.GameObjectA is IPaddle && collision.GameObjectB is IBlock)) { PaddleBlockCollisionHandler collisionHandler = new PaddleBlockCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IPaddleBall && collision.GameObjectB is IPaddle) || (collision.GameObjectA is IPaddle && collision.GameObjectB is IPaddleBall)) { PaddlePaddleBallCollisionHandler collisionHandler = new PaddlePaddleBallCollisionHandler(collision); collisionHandler.HandleCollision(); } else if ((collision.GameObjectA is IPaddleBall && collision.GameObjectB is IBlock) || (collision.GameObjectA is IBlock && collision.GameObjectB is IPaddleBall)) { PaddleBallBlockCollisionHandler collisionHandler = new PaddleBallBlockCollisionHandler(collision, gameState); collisionHandler.HandleCollision(); } }