public void NormalMarioKoopaRightSideCollisionTest() { 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 NormalRightIdleState(testMario); expectedMario.MarioState = new NormalRightIdleState(expectedMario); expectedMario.Damage(); GreenKoopa testGreenKoopa = new GreenKoopa(game); ICollisionSide side = new RightSideCollision(); 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 FireMarioGoombaBottomSideCollisionTest() { IMario testMario = new MarioInstance(game); testMario.VectorCoordinates = new Vector2(0, 14); IMario expectedMario = new MarioInstance(game); expectedMario.VectorCoordinates = new Vector2(0, 16); testMario.MarioState = new FireRightIdleState(testMario); expectedMario.MarioState = new FireRightIdleState(expectedMario); expectedMario.Damage(); Goomba testGoomba = new Goomba(game); ICollisionSide side = new BottomSideCollision(); 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 FireMarioRedMushroomTopSideCollisionTest() { 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 TopSideCollision(); 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 SmallMarioStarTopSideCollisionTest() { WorldManager.LoadListFromFile("World1-1", game); MarioInstance testMario = new MarioInstance(game); MarioInstance expectedMario = new MarioInstance(game); expectedMario.VectorCoordinates = new Vector2(0, 0); expectedMario.Star(); Star testStar = new Star(game); Star expectedStar = new Star(game); expectedStar.Disappear(); ICollisionSide side = new TopSideCollision(); 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 BigMarioGreenMushroomRightSideCollisionTest() { 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 RightSideCollision(); 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 BigMarioFlowerLeftSideCollisionTest() { MarioInstance testMario = new MarioInstance(game); MarioInstance expectedMario = new MarioInstance(game); testMario.Mushroom(); expectedMario.Mushroom(); 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 void FireMarioHiddenBlockTopSideCollisionTest() { MarioInstance testMario = new MarioInstance(game); MarioInstance expectedMario = new MarioInstance(game); Block testBlock = new Block(Block.Type.HiddenBlock, game); Block expectedBlock = new Block(Block.Type.HiddenBlock, game); ICollisionSide side = new TopSideCollision(); CollisionData collision = new CollisionData(testMario, testBlock, side); MarioBlockCollisionHandler collisionHandler = new MarioBlockCollisionHandler(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 BigMarioQuestionBlockRightSideCollisionTest() { MarioInstance testMario = new MarioInstance(game); MarioInstance expectedMario = new MarioInstance(game); Block testBlock = new Block(Block.Type.QuestionBlock, game); Block expectedBlock = new Block(Block.Type.QuestionBlock, game); expectedMario.VectorCoordinates = new Vector2(12, 0); ICollisionSide side = new RightSideCollision(); CollisionData collision = new CollisionData(testMario, testBlock, side); MarioBlockCollisionHandler collisionHandler = new MarioBlockCollisionHandler(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 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 SmallMarioKoopaBottomSideCollisionTest() { 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 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 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 void SmallMarioBreakingBlockBottomSideCollisionTest() { MarioInstance testMario = new MarioInstance(game); MarioInstance expectedMario = new MarioInstance(game); expectedMario.VectorCoordinates = new Vector2(0, 15); Block testBlock = new Block(Block.Type.BreakingBlock, game); Block expectedBlock = new Block(Block.Type.BreakingBlock, game); ICollisionSide side = new BottomSideCollision(); CollisionData collision = new CollisionData(testMario, testBlock, side); MarioBlockCollisionHandler collisionHandler = new MarioBlockCollisionHandler(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); }
private static List<IGameObject> CreateNewGameObjects(List<string[]> objectList, Game1 game) { List<IGameObject> gameObjects = new List<IGameObject>(); Vector2 location = new Vector2(0,0); objectList.RemoveAt(0); foreach(string[] line in objectList) { foreach(string objectName in line) { IGameObject gameObject = null; IGameObject objectsItem = null; if (objectName.Equals("Mario")) gameObject = new MarioInstance(game); if (objectName.Equals("InvisiMario")) gameObject = new InvisiMario(game); if (objectName.Equals("PacMario")) gameObject = new PacMario(game); else if (objectName.Equals("Coin")) gameObject = new Coin(false, game); else if (objectName.Equals("PacNormCoin")) gameObject = new PacMarioNormalCoin(false, game); else if (objectName.Equals("PacMarioCoin")) gameObject = new PacMarioCoin(false, game); else if (objectName.Equals("Flower")) gameObject = new Flower(false, game); else if (objectName.Equals("GreenMush")) gameObject = new GreenMushroom(false, game); else if (objectName.Equals("RedMush")) gameObject = new RedMushroom(false, game); else if (objectName.Equals("Star")) gameObject = new Star(false, game); else if (objectName.Equals("Koopa")) gameObject = new GreenKoopa(game); else if (objectName.Equals("Goomba")) gameObject = new Goomba(game); else if (objectName.Equals("Boo1")) gameObject = new Boo(game, IEnemyObjectConstants.BOO_START_LOCATIONS[0]); else if (objectName.Equals("Boo2")) gameObject = new Boo(game, IEnemyObjectConstants.BOO_START_LOCATIONS[1]); else if (objectName.Equals("Boo3")) gameObject = new Boo(game, IEnemyObjectConstants.BOO_START_LOCATIONS[2]); else if (objectName.Equals("Boo4")) gameObject = new Boo(game, IEnemyObjectConstants.BOO_START_LOCATIONS[3]); else if (objectName.Equals("Castle")) gameObject = new Castle(game); else if (objectName.Equals("FlagPole")) gameObject = new FlagPole(game); else if (objectName.Equals("FlagPoleBarrier")) gameObject = new InvisibleFlagPoleBarrier(game); else if (objectName.Equals("SolidBlock")) gameObject = new Block(Block.Type.SolidBlock, false, game); else if (objectName.Equals("HBlockWall")) gameObject = new Block(Block.Type.HorizontalBlockWall, false, game); else if (objectName.Equals("VBlockWall")) gameObject = new Block(Block.Type.VerticalBlockWall, false, game); else if (objectName.Equals("InvisCoinBlock")) { objectsItem = new Coin(true, game); gameObject = new Block(Block.Type.HiddenBlock, false, game); } else if (objectName.Equals("InvisGreenMushBlock")) { objectsItem = new GreenMushroom(true, game); gameObject = new Block(Block.Type.HiddenBlock, false, game); } else if (objectName.Equals("QuestionCoinBlock")) { objectsItem = new Coin(true, game); gameObject = new Block(Block.Type.QuestionBlock, false, game); } else if (objectName.Equals("BrickCoinBlock")) { objectsItem = new Coin(true, game); gameObject = new Block(Block.Type.BrickBlock, false, game); } else if (objectName.Equals("QuestionRedMushBlock")) { objectsItem = new RedMushroom(true, game); gameObject = new Block(Block.Type.QuestionBlock, false, game); } else if (objectName.Equals("QuestionGreenMushBlock")) { objectsItem = new GreenMushroom(true, game); gameObject = new Block(Block.Type.QuestionBlock, false, game); } else if (objectName.Equals("QuestionFlowerBlock")) { objectsItem = new Flower(true, game); gameObject = new Block(Block.Type.QuestionBlock, false, game); } else if (objectName.Equals("QuestionStarBlock")) { objectsItem = new Star(true, game); gameObject = new Block(Block.Type.QuestionBlock, false, game); } else if (objectName.Equals("BrickStarBlock")) { objectsItem = new Star(true, game); gameObject = new Block(Block.Type.BrickBlock, false, game); } else if (objectName.Equals("BrickBlock")) gameObject = new Block(Block.Type.BrickBlock, false, game); else if (objectName.Equals("UndergroundBrickBlock")) gameObject = new Block(Block.Type.BrickBlock, true, game); else if (objectName.Equals("BreakingBlock")) gameObject = new Block(Block.Type.BreakingBlock, false, game); else if (objectName.Equals("UndergroundBreakingBlock")) gameObject = new Block(Block.Type.BreakingBlock, true, game); else if (objectName.Equals("EnemyUpBlock")) gameObject = new Block(Block.Type.EnemyUpBlock, true, game); else if (objectName.Equals("EnemyDownBlock")) gameObject = new Block(Block.Type.EnemyDownBlock, true, game); else if (objectName.Equals("EnemyRightBlock")) gameObject = new Block(Block.Type.EnemyRightBlock, true, game); else if (objectName.Equals("EnemyLeftBlock")) gameObject = new Block(Block.Type.EnemyLeftBlock, true, game); else if (objectName.Equals("TeleportBlock")) gameObject = new Block(Block.Type.TeleportBlock, false, game); else if (objectName.Equals("Pipe")) gameObject = new Pipe(game); else if (objectName.Equals("DoublePipe")) gameObject = new DoublePipe(game); else if (objectName.Equals("TriplePipe")) gameObject = new TriplePipe(game); else if (objectName.Equals("SidePipe")) gameObject = new SidePipe(game); else if (objectName.Equals("VerticalPipe")) gameObject = new VerticalPipe(game); else if (objectName.StartsWith("TripleWarpPipe")) { string[] parsedName = objectName.Split('-'); float x = Int32.Parse(parsedName[1]); float y = Int32.Parse(parsedName[2]); gameObject = new TriplePipe(new Vector2(x, y), game); } else if (objectName.StartsWith("TripleGameStatePipe")) { string[] parsedName = objectName.Split('-'); IGameState gameState = createNewGameState(parsedName[1], game); gameObject = new TriplePipe(gameState, game); } else if (objectName.StartsWith("SideWarpPipe")) { string[] parsedName = objectName.Split('-'); float x = Int32.Parse(parsedName[1]); float y = Int32.Parse(parsedName[2]); gameObject = new SidePipe(new Vector2(x, y), game); } else if (objectName.Equals("BigHill")) gameObject = new BigHill(game); else if (objectName.Equals("Bush")) gameObject = new SingleBush(game); else if (objectName.Equals("Cloud")) gameObject = new SingleCloud(game); else if (objectName.Equals("SmHill")) gameObject = new SmallHill(game); else if (objectName.Equals("TripleBush")) gameObject = new TripleBush(game); else if (objectName.Equals("TripleCloud")) gameObject = new TripleCloud(game); else if (objectName.Equals("Buckeye")) gameObject = new BuckeyePlayer(game); else if (objectName.Equals("Wolverine")) gameObject = new WolverineEnemy(game); else if (objectName.Equals("JmpWolverine")) gameObject = new JumpingWolverineEnemy(game); else if (objectName.Equals("WolverineChuck")) gameObject = new WolverineChuck(game); else if (objectName.Equals("ThwWolverine")) gameObject = new ThrowingWolverineEnemy(game); else if (objectName.Equals("BuckeyeGrass")) gameObject = new GrassTile(game); else if (objectName.Equals("BuckeyeGround")) gameObject = new GroundTile(game); else if (objectName.Equals("BuckeyeStone")) gameObject = new StoneTile(game); else if (objectName.Equals("StoneWall")) gameObject = new GiantVerticalStoneWall(game); else if (objectName.Equals("Paddle")) gameObject = new Paddle(game); else if (objectName.Equals("PaddleBall")) gameObject = new PaddleBall(game); else if (objectName.Equals("ElevatorU")) gameObject = new Elevator(true, game); else if (objectName.Equals("ElevatorD")) gameObject = new Elevator(false, game); else if (objectName.Equals("Endblock")) gameObject = new Endblock(game); if (objectsItem != null) { objectsItem.VectorCoordinates = location + new Vector2(0, -objectsItem.Sprite.SpriteDimensions.Y); gameObjects.Add(objectsItem); } if(gameObject != null){ gameObject.VectorCoordinates = location + new Vector2(0, -gameObject.Sprite.SpriteDimensions.Y + 16); if (gameObject is IFlagPole) gameObject.VectorCoordinates += new Vector2(0,16); gameObjects.Add(gameObject); } location.X += 16; } location.Y += 16; location.X = 0; } for(int index = 0; index < gameObjects.Count; index++) { if (gameObjects[index] is IMario) { IGameObject mario = gameObjects[index]; gameObjects.RemoveAt(index); gameObjects.Add(mario); break; } } for (int index = 0; index < gameObjects.Count; index++) { if (gameObjects[index] is IScenery) { IGameObject scenery = gameObjects[index]; gameObjects.RemoveAt(index); gameObjects.Insert(0, scenery); } } for (int index = gameObjects.Count - 1; index > 0; index--) { if (gameObjects[index] is IPipe) { IGameObject pipe = gameObjects[index]; gameObjects.RemoveAt(index); gameObjects.Add(pipe); } } return gameObjects; }