예제 #1
0
 public Level(string fileName)
 {
     this.game = Game1.GetInstance();
     builder   = new LevelBuilder(this);
     mario     = builder.Build(fileName);
     game.gameCamera.LookAt(mario.position);
     collision         = new CollisionDetector(mario, game);
     exitPole          = new GateSprite(Game1.gameContent.Load <Texture2D>("Items/gateFramedFinal"), 2, 23);
     game.gameHUD.Time = ValueHolder.startingTime;
 }
예제 #2
0
        public void SmallMarioEnemyBottomCollision()
        {
            //arrange
            game.level.mario = new Mario(game, starting);
            CollisionDetector collision = new CollisionDetector(game);
            Enemy             enemy     = new Enemy(game, Enemy.Enemies.Dino, new Vector2(250, 440));

            levelEnemies.Add(enemy);
            //act
            collision.Detect(game.level.mario, levelEnemies, levelBlocks, levelItems);
            //assert
            if ((new DeadMS(game).GetType()) == game.level.mario.state.GetType())
            {
                fileOut.WriteLine("SmallMarioEnemyBottomCollision: Passed");
            }
            else
            {
                fileOut.WriteLine("SmallMarioEnemyBottomCollision: Failed");
            }
        }
예제 #3
0
        public void BigMarioBrickBlockBottomCollision()
        {
            //arrange
            game.level.mario = new Mario(game, starting);
            CollisionDetector collision = new CollisionDetector(game);
            Block             block     = new Block(game, Block.BlockType.brick, new Vector2(250, 445));

            levelBlocks.Add(block);
            //act
            collision.Detect(game.level.mario, levelEnemies, levelBlocks, levelItems);
            //assert
            if (new List <Block>() == levelBlocks)
            {
                fileOut.WriteLine("BigMarioBrickBottomCollision: Passed");
            }
            else
            {
                fileOut.WriteLine("BigMarioBrickBottomCollision: Failed");
            }
        }
예제 #4
0
        public void SmallMarioFlowerCollision()
        {
            //arrange
            game.level.mario = new Mario(game, starting);
            CollisionDetector collision = new CollisionDetector(game);
            IAnimatedSprite   flower    = factory.build(SpriteFactory.sprites.fireFlower);
            Item item = new Item(flower);

            item.xpos = 250;
            item.ypos = 450;
            levelItems.Add(item);
            //act
            collision.Detect(game.level.mario, levelEnemies, levelBlocks, levelItems);
            //assert
            if ((new RightIdleFireMS(game).GetType()) == game.level.mario.state.GetType())
            {
                fileOut.WriteLine("SmallMarioFlowerCollision: Passed");
            }
            else
            {
                fileOut.WriteLine("SmallMarioFlowerCollision: Failed");
            }
        }
예제 #5
0
        public void MarioStarCollision()
        {
            //arrange
            game.level.mario = new Mario(game, starting);
            CollisionDetector collision = new CollisionDetector(game);
            IAnimatedSprite   star      = factory.build(SpriteFactory.sprites.star);
            Item item = new Item(star);

            item.xpos = 250;
            item.ypos = 450;
            levelItems.Add(item);
            //act
            collision.Detect(game.level.mario, levelEnemies, levelBlocks, levelItems);
            //assert
            if (game.level.mario.marioIsStar)
            {
                fileOut.WriteLine("MarioStarCollision: Passed");
            }
            else
            {
                fileOut.WriteLine("MarioStarCollision: Failed");
            }
        }
예제 #6
0
        public void Mario1UpCollision()
        {
            //arrange
            game.level.mario = new Mario(game, starting);
            levelItems       = new List <Item>();
            CollisionDetector collision = new CollisionDetector(game);
            IAnimatedSprite   oneUp     = factory.build(SpriteFactory.sprites.oneUpMushroom);
            Item item = new Item(oneUp);

            item.xpos = 250;
            item.ypos = 450;
            levelItems.Add(item);
            //act
            collision.Detect(game.level.mario, levelEnemies, levelBlocks, levelItems);
            //assert
            if (levelItems == new List <Item>())
            {
                fileOut.WriteLine("Mario1UpCollision: Passed");
            }
            else
            {
                fileOut.WriteLine("Mario1UpCollision: Failed");
            }
        }