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 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 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); }
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; }