Example #1
0
        public void MarioAboveKoopaTest()
        {
            //Make Mario, Koopa, and Movement Command
            IMario mario = new Mario(new Vector2(500, 250));
            IEnemy koopa = new Koopa(new Vector2(500, 500));

            level       = new Level(game);
            level.Mario = mario;
            ICommand moveDown = new DownCommand(level);

            //Move Mario Down until he has fallen past the Koopa
            Rectangle marioPosition = mario.DrawnRectangle;

            while (marioPosition.Y < 500 - marioPosition.Height)
            {
                moveDown.Execute();
                level.Update();
                marioPosition = mario.DrawnRectangle;
            }

            //Check test results, Mario should live
            if (mario.IsDead())
            {
                writer.WriteLine("Mario Above Koopa Test: Unsuccessful\n");
            }

            else
            {
                writer.WriteLine("Mario Above Koopa Test: Successful\n");
            }
        }
Example #2
0
        public void MarioRightSideKoopaTest()
        {
            //Make Mario, Koopa, and Movement Command
            IMario mario = new Mario(new Vector2(750, 500));
            IEnemy koopa = new Koopa(new Vector2(500, 500));

            level       = new Level(game);
            level.Mario = mario;
            ICommand moveLeft = new LeftCommand(level);

            //Move Mario Left until he has run past the Koopa
            Rectangle marioPosition = mario.DrawnRectangle;

            while (marioPosition.X > 490)
            {
                moveLeft.Execute();
                level.Update();
                marioPosition = mario.DrawnRectangle;
            }

            //Check test results, Mario should die
            if (!mario.IsDead())
            {
                writer.WriteLine("Mario Right Side Koopa Test: Unsuccessful\n");
            }

            else
            {
                writer.WriteLine("Mario Right Side Koopa Test: Successful\n");
            }
        }
Example #3
0
 public KoopaSprite(Koopa koopa)
 {
     this.Koopa        = koopa;
     this.Texture      = SpriteHolder.Koopa;
     this.CurrentFrame = SpriteHolder.WalkingKoopaStartFrame;
     this.LastFrame    = SpriteHolder.WalkingKoopaStartFrame + SpriteHolder.WalkingKoopaFrames;
     this.Width        = SpriteHolder.KoopaWidth;
     this.Height       = this.Texture.Height;
 }
Example #4
0
        private IEnemy CreateSpawnEnemy()
        {
            IEnemy          spawnEnemy    = new Goomba(this.CurrentPosition, true);
            EnemyDescriptor randomPowerup = (EnemyDescriptor)this.RandomNumber.Next(0, EnemySpawnerConfig.NumberOfUniqueEnemies);
            bool            rightFacing   = this.RandomNumber.Next(0, 2) == 1;

            switch (randomPowerup)
            {
            case EnemyDescriptor.Goomba:
                spawnEnemy = new Goomba(this.CurrentPosition, rightFacing);
                break;

            case EnemyDescriptor.Koopa:
                spawnEnemy = new Koopa(this.CurrentPosition, rightFacing);
                break;
            }
            return(spawnEnemy);
        }
 public KoopaCollisionResponder(Koopa koopa)
 {
     this.Koopa = koopa;
 }
Example #6
0
        public void SpawnEnemy(Vector2 Position, String s)
        {
            IEnemy e;

            switch (s[1])
            {
            case 'G':
                if (s.Length > 2 && s[2] == 'R')
                {
                    e = new Goomba(Position, true);
                }
                else
                {
                    e = new Goomba(Position, false);
                }
                this.level.Enemies.Add(e);
                break;

            case 'K':
                if (s.Length > 2 && s[2] == 'R')
                {
                    e = new Koopa(Position, true);
                }
                else
                {
                    e = new Koopa(Position, false);
                }
                this.level.Enemies.Add(e);
                break;

            case 'F':
                if (s.Length > 2 && s[2] == 'R')
                {
                    e = new FlyingKoopa(Position, true);
                }
                else
                {
                    e = new FlyingKoopa(Position, false);
                }
                this.level.Enemies.Add(e);
                break;

            case 'S':
                if (s.Length > 2 && s[2] == 'R')
                {
                    e = new Spiny(Position, true);
                }
                else
                {
                    e = new Spiny(Position, false);
                }
                this.level.Enemies.Add(e);
                break;

            case 'L':
                if (s.Length > 2 && s[2] == 'R')
                {
                    e = new Lakitu(Position, this.level);
                }
                else
                {
                    e = new Lakitu(Position, this.level);
                }
                this.level.Enemies.Add(e);
                break;
            }
        }