public void FireMarioGoombaRightSideCollisionTest() { IMario testMario = new MarioInstance(game); testMario.VectorCoordinates = new Vector2(14, 0); IMario expectedMario = new MarioInstance(game); expectedMario.VectorCoordinates = new Vector2(16, 0); testMario.MarioState = new FireRightIdleState(testMario); expectedMario.MarioState = new FireRightIdleState(expectedMario); expectedMario.Damage(); Goomba testGoomba = new Goomba(game); ICollisionSide side = new RightSideCollision(); CollisionData collision = new CollisionData(testMario, testGoomba, side); MarioEnemyCollisionHandler collisionHandler = new MarioEnemyCollisionHandler(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 NormalMarioKoopaLeftSideCollisionTest() { MarioInstance testMario = new MarioInstance(game); MarioInstance expectedMario = new MarioInstance(game); expectedMario.VectorCoordinates = new Vector2(-1, 0); testMario.MarioState = new NormalRightIdleState(testMario); expectedMario.MarioState = new NormalRightIdleState(expectedMario); expectedMario.Damage(); GreenKoopa testGreenKoopa = new GreenKoopa(game); testGreenKoopa.VectorCoordinates = new Vector2(14, 0); ICollisionSide side = new LeftSideCollision(); CollisionData collision = new CollisionData(testMario, testGreenKoopa, side); MarioEnemyCollisionHandler collisionHandler = new MarioEnemyCollisionHandler(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 SmallMarioGoombaLeftSideCollisionTest() { MarioInstance testMario = new MarioInstance(game); MarioInstance expectedMario = new MarioInstance(game); expectedMario.VectorCoordinates = new Vector2(-1, 0); expectedMario.Damage(); Goomba testGoomba = new Goomba(game); testGoomba.VectorCoordinates = new Vector2(11, 0); ICollisionSide side = new LeftSideCollision(); CollisionData collision = new CollisionData(testMario, testGoomba, side); MarioEnemyCollisionHandler collisionHandler = new MarioEnemyCollisionHandler(collision); collisionHandler.HandleCollision(); bool testState = testMario.MarioState is DeadMarioState; bool expectedState = expectedMario.MarioState is DeadMarioState; Vector2 testLocation = testMario.VectorCoordinates; Vector2 expectedLocation = expectedMario.VectorCoordinates; Assert.AreEqual(testState, expectedState); Assert.AreEqual(testLocation, expectedLocation); }
public void SmallMarioGoombaTopSideCollisionTest() { IMario testMario = new MarioInstance(game); Goomba testGoomba = new Goomba(game); testGoomba.VectorCoordinates = new Vector2(0, 14); Goomba expectedGoomba = new Goomba(game); expectedGoomba.Hit(); ICollisionSide side = new TopSideCollision(); CollisionData collision = new CollisionData(testMario, testGoomba, side); MarioEnemyCollisionHandler collisionHandler = new MarioEnemyCollisionHandler(collision); collisionHandler.HandleCollision(); bool testState = testGoomba.state is GoombaSmashedState; bool expectedState = expectedGoomba.state is GoombaSmashedState; Vector2 testLocation = testMario.VectorCoordinates; Vector2 expectedLocation = new Vector2(0, -1); Assert.AreEqual(testState, expectedState); Assert.AreEqual(testLocation, expectedLocation); }
public void StarSmallMarioGoombaTopCollisionTest() { WorldManager.LoadListFromFile("World1-1", game); IMario testMario = WorldManager.GetMario(); testMario.Star(); testMario = WorldManager.GetMario(); testMario.VectorCoordinates = new Vector2(0, 0); Goomba testGoomba = new Goomba(game); testGoomba.VectorCoordinates = new Vector2(0, 14); Goomba expectedGoomba = new Goomba(game); expectedGoomba.Flipped(); ICollisionSide side = new TopSideCollision(); CollisionData collision = new CollisionData(testMario, testGoomba, side); MarioEnemyCollisionHandler collisionHandler = new MarioEnemyCollisionHandler(collision); collisionHandler.HandleCollision(); bool testState = testGoomba.state is GoombaFlippedState; bool expectedState = expectedGoomba.state is GoombaFlippedState; Vector2 testLocation = testMario.VectorCoordinates; Vector2 expectedLocation = new Vector2(0, -1); Assert.AreEqual(testState, expectedState); Assert.AreEqual(testLocation, expectedLocation); }
public void StarNormalMarioKoopaTopCollisionTest() { WorldManager.LoadListFromFile("World1-1", game); IMario testMario = WorldManager.GetMario(); testMario.Mushroom(); testMario.Star(); testMario = WorldManager.GetMario(); testMario.VectorCoordinates = new Vector2(0, 0); GreenKoopa testGreenKoopa = new GreenKoopa(game); testGreenKoopa.VectorCoordinates = new Vector2(0, 30); GreenKoopa expectedGreenKoopa = new GreenKoopa(game); expectedGreenKoopa.Flipped(); ICollisionSide side = new TopSideCollision(); CollisionData collision = new CollisionData(testMario, testGreenKoopa, side); MarioEnemyCollisionHandler collisionHandler = new MarioEnemyCollisionHandler(collision); collisionHandler.HandleCollision(); bool testState = testGreenKoopa.state is GreenKoopaFlippedInShellState; bool expectedState = expectedGreenKoopa.state is GreenKoopaFlippedInShellState; Vector2 testLocation = testMario.VectorCoordinates; Vector2 expectedLocation = new Vector2(0, -1); Assert.AreEqual(testState, expectedState); Assert.AreEqual(testLocation, expectedLocation); }
public void NormalMarioKoopaTopSideCollisionTest() { IMario testMario = new MarioInstance(game); testMario.MarioState = new NormalRightIdleState(testMario); GreenKoopa testGreenKoopa = new GreenKoopa(game); testGreenKoopa.VectorCoordinates = new Vector2(0, 30); GreenKoopa expectedGreenKoopa = new GreenKoopa(game); expectedGreenKoopa.Hit(); ICollisionSide side = new TopSideCollision(); CollisionData collision = new CollisionData(testMario, testGreenKoopa, side); MarioEnemyCollisionHandler collisionHandler = new MarioEnemyCollisionHandler(collision); collisionHandler.HandleCollision(); bool testState = testGreenKoopa.state is GreenKoopaHidingInShellState; bool expectedState = expectedGreenKoopa.state is GreenKoopaHidingInShellState; Vector2 testLocation = testMario.VectorCoordinates; Vector2 expectedLocation = new Vector2(0, -1); 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(); } }
public void FireMarioKoopaBottomSideCollisionTest() { IMario testMario = new MarioInstance(game); testMario.VectorCoordinates = new Vector2(0, 19); IMario expectedMario = new MarioInstance(game); expectedMario.VectorCoordinates = new Vector2(0, 21); expectedMario.Damage(); GreenKoopa testGreenKoopa = new GreenKoopa(game); ICollisionSide side = new BottomSideCollision(); CollisionData collision = new CollisionData(testMario, testGreenKoopa, side); MarioEnemyCollisionHandler collisionHandler = new MarioEnemyCollisionHandler(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); }