예제 #1
1
        public void SmallMarioGoombaBottomSideCollisionTest()
        {
            IMario testMario = new MarioInstance(game);

            testMario.VectorCoordinates = new Vector2(0, 14);
            IMario expectedMario = new MarioInstance(game);

            expectedMario.VectorCoordinates = new Vector2(0, 16);
            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 DeadMarioState;
            bool    expectedState    = expectedMario.MarioState is DeadMarioState;
            Vector2 testLocation     = testMario.VectorCoordinates;
            Vector2 expectedLocation = expectedMario.VectorCoordinates;

            Assert.AreEqual(testState, expectedState);
            Assert.AreEqual(testLocation, expectedLocation);
        }
 public GoombaFlippedState(Goomba goomba)
 {
     this.goomba = goomba;
     SoundEffectManager.EnemyFlippedEffect();
     goomba.Physics.Velocity = new Vector2(0, EnemyStatesConstants.FLIPPEDYVELOCITY);
     goomba.Physics.Acceleration = new Vector2(0, EnemyStatesConstants.GRAVITY);
     this.goomba.IsFlipped = true;
     this.goomba.Sprite = Game.SpriteFactories.EnemySpriteFactory.CreateGoombaFlippedSprite();
 }
예제 #3
1
 public GoombaStompedState(Goomba goomba)
 {
     this.goomba = goomba;
     sprite      = EnemyFactory.Instance.CreateGoombaStompedSprite();
     Width       = sprite.Width;
     Height      = sprite.Height;
     time        = Constant.Instance.MarioDelay;
     Removal     = false;
 }
예제 #4
0
 public override void TakeDamage(string killType)
 {
     if (killType.Equals("fire"))
     {
         hitPoints = 0;
         ass.Stop();
         leftWing.Stop();
         rightWing.Stop();
         col.enabled = false;
         GetComponent <BoxCollider2D>().enabled = false;
         if (isFacingRight)
         {
             rb.velocity = new Vector2(1f, 10f) * Xvel;
         }
         else
         {
             rb.velocity = new Vector2(-1f, 10f) * Xvel;
         }
         transform.localScale = new Vector2(transform.localScale.x, -transform.localScale.y);
         destroyOnExit        = true;
         rb.gravityScale      = 7;
     }
     else if (killType.Equals("stomp"))
     {
         Goomba g = Instantiate(Goomba, transform.position, Quaternion.identity).GetComponent <Goomba>();
         g.StartCoroutine(g.StartFromPara(isFacingRight));
         Destroy(gameObject);
     }
 }
        public GoombaWalkingRightState(Goomba goomba)
        {
            this.goomba = goomba;
            this.goomba.Sprite = Game.SpriteFactories.EnemySpriteFactory.CreateGoombaWalkingRightSprite();

            goomba.Physics.Velocity = new Vector2(EnemyStatesConstants.WALKINGRIGHTVELOCITY, 0);
        }
    public void StartBounce()
    {
        AudioManager.PlaySound(AudioManager.main.bump, 1);
        bouncing         = true;
        bounceFrame      = 0;
        originalposition = transform.position;
        Transform enemies = GameObject.Find("Enemies").transform;

        for (int i = 0; i < enemies.childCount; i++)
        {
            Transform enemie = enemies.GetChild(i);
            if (enemie.position.y > transform.position.y && enemie.position.y < transform.position.y + 1.5f &&
                enemie.position.x > transform.position.x - 1 && enemie.position.x < transform.position.x + 1)
            {
                Goomba goomba = enemie.GetComponent <Goomba>();
                if (goomba != null)
                {
                    goomba.Kill();
                }
                else
                {
                    Destroy(enemie.gameObject);
                }
            }
        }
    }
예제 #7
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        Goomba goomba = collision.collider.GetComponent <Goomba>();

        if (goomba != null)
        {
            // Fireball has kicked a goomba
            goomba.Hurt();
            ExplodeImmediately();
        }
        else
        {
            Vector2 normal     = collision.contacts[0].normal;
            Vector2 leftSide   = new Vector2(-1f, 0f);
            Vector2 rightSide  = new Vector2(1f, 0f);
            Vector2 bottomSide = new Vector2(0f, 1f);

            if (normal == leftSide || normal == rightSide)
            { // explode if side hit
                Explode();
            }
            else if (normal == bottomSide)
            { // bounce off
                rigidbody.velocity = new Vector2(rigidbody.velocity.x, absVelocity.y);
            }
            else
            {
                rigidbody.velocity = new Vector2(rigidbody.velocity.x, -absVelocity.y);
            }
        }
    }
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
 public void Handle(ICollidable player, ICollidable goomba, CollisionDirection.DirectionTag direction)
 {
     if (player.GetType() == typeof(Mario) && goomba.GetType() == typeof(Goomba))
     {
         this.player = (Mario)player;
         this.goomba = (Goomba)goomba;
         if (direction == CollisionDirection.DirectionTag.Top)
         {
             this.player.Physics.yPosition  = this.goomba.GetTopSide() - this.player.GetHeight();
             this.player.Physics.yVelocity *= -1;
             this.goomba.Kill();
             this.goomba.Stomp();
         }
         else if (direction == CollisionDirection.DirectionTag.Bottom ||
                  direction == CollisionDirection.DirectionTag.Left ||
                  direction == CollisionDirection.DirectionTag.Right)
         {
             if (this.player.IsBig() || this.player.IsFire())
             {
                 this.player.TakeDamage();
             }
             else if (this.player.IsSmall())
             {
                 this.player.TakeDamage();
             }
             //player.IsStar()
             else
             {
                 this.goomba.Kill();
                 this.goomba.Fall();
             }
         }
     }
 }
예제 #11
0
        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);
        }
예제 #12
0
        public static void HandleGoombaCollision(Goomba goomba, IEnemy collidedEnemy, CollisionSide side)
        {
            Physics.GeneralPhysics.RepelObject(collidedEnemy, goomba, side);

            if (!IsHorizontalCollision(side))
            {
                return;
            }

            switch (collidedEnemy)
            {
            case Goomba collidedGoomba:
                collidedGoomba.ChangeDirection(GetOppositeSide(side));
                break;

            case Koopa collidedKoopa:
                if (collidedKoopa.IsKicked)
                {
                    goomba.TakeDamage();
                    SoundFactory.Instance.PlayKickEnemySound();
                }
                else
                {
                    collidedKoopa.ChangeDirection(GetOppositeSide(side));
                }
                break;
            }
            goomba.ChangeDirection(side);
        }
예제 #13
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Goomba goomba = collision.collider.GetComponent <Goomba>();

        if (goomba != null)
        {
            foreach (ContactPoint2D point in collision.contacts)
            {
                Debug.Log(point.normal);
                Debug.DrawLine(point.point, point.point + point.normal, Color.red, 10);
                if (point.normal.y >= 0.6f)
                {
                    Vector2 velocity = rb.velocity;
                    velocity.y  = jumpSpeed;
                    rb.velocity = velocity;
                    goomba.Hurt();
                }
                else
                {
                    Hurt();
                    break;
                }
            }
        }
    }
        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);
        }
예제 #15
0
    public static bool beginCollisionWithPlayer(ChipmunkArbiter arbiter)
    {
        ChipmunkShape shape1, shape2;

        arbiter.GetShapes(out shape1, out shape2);

        Goomba goomba = shape1.GetComponent <Goomba>();
        Player player = shape2.GetComponent <Player>();

        if (goomba.dieAnim.isDying() || player.isDying())
        {
            arbiter.Ignore();         // avoid the collision to continue since this frame
            return(false);            // avoid the collision to continue since this frame
        }

        goomba.idle.setIdle(true);

        // if collides from top then kill the goomba
        if (GameObjectTools.isHitFromAbove(goomba.transform.position.y, shape2.body, arbiter))
        {
            goomba.die();
            // makes the player jumps a little upwards
            player.forceJump();
        }
        // kills Player
        else
        {
            arbiter.Ignore();                     // avoid the collision to continue since this frame
            LevelManager.Instance.loseGame(true); // force die animation
        }

        // Returning false from a begin callback means to ignore the collision response for these two colliding shapes
        // until they separate. Also for current frame. Ignore() does the same but next frame.
        return(true);
    }
 // This function is called whenever the state is entered
 public override void OnEnterState()
 {
     player       = GameObject.Find("Player");
     goombaScript = GetComponentInParent <Goomba>();
     GetComponentInParent <Particle3D>().AddForce(GetComponentInParent <Particle3D>().mass *Vector3.up *alertJumpStrength);
     goombaScript.SetHoppingState(true);
     goombaScript.SetChasingState(true);
 }
예제 #17
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     Mario   = new Mario();
     Goomba  = new Goomba(random.Next(100, 800));
     Goomba2 = new Goomba(random.Next(100, 800));
     life    = new Rectangle(300, 230, 48, 48);
     base.Initialize();
 }
예제 #18
0
 public GoombaMovingState(Goomba goomba)
 {
     this.goomba = goomba;
     sprite      = EnemyFactory.Instance.CreateGoombaMovingLeftSprite();
     Width       = sprite.Width;
     Height      = sprite.Height;
     Removal     = false;
 }
예제 #19
0
 public void Init()
 {
     _contentManager = new TestContentManager();
     _level          = new Level();
     _goomba         = new Goomba(0, 0, _level, _contentManager);
     _level.ToAddGameObject(_goomba);
     _level.UpdateLevel();
 }
예제 #20
0
 private void RestartGame()
 {
     finish_sound.Dispose();
     currentState = GameState.Menu;
     Mario        = new Mario();
     Goomba       = new Goomba(random.Next(100, 600));
     Goomba2      = new Goomba(random.Next(300, 800));
     life         = new Rectangle(300, 230, 48, 48);
 }
 public GoombaSmashedState(Goomba goomba)
 {
     this.goomba = goomba;
     SoundEffectManager.GoombaHitEffect();
     this.goomba.IsHit = true;
     float prevHeight = goomba.Sprite.SpriteDimensions.Y;
     this.goomba.Sprite = Game.SpriteFactories.EnemySpriteFactory.CreateGoombaSmashedSprite();
     goomba.VectorCoordinates += new Microsoft.Xna.Framework.Vector2(0,prevHeight - goomba.Sprite.SpriteDimensions.Y);
 }
예제 #22
0
        public void Goomba_FacingTest()
        {
            Goomba goomba = new Goomba(new Vector2(0, 0));

            bool actual = goomba.FacingRight;

            bool expected = false;

            Assert.AreEqual(expected, actual);
        }
예제 #23
0
        public GoombaWalkingState(Goomba goomba)
        {
            this.goomba = goomba;
            sprite      = EnemySpriteFactory.Instance.CreateGoombaMovingSprite();
            Width       = sprite.Width;
            Height      = sprite.Height;

            goomba.EnemyPhysics.EnemyWalk();
            goomba.EnemyPhysics.GoombaMove();
        }
예제 #24
0
        public GoombaFlippedState(Goomba goomba)
        {
            this.goomba            = goomba;
            goomba.EnemyCollidable = true;
            sprite = EnemySpriteFactory.Instance.CreateGoombaFlippedSprite();
            Width  = sprite.Width;
            Height = sprite.Height;

            goomba.EnemyPhysics.Flip();
        }
예제 #25
0
        public GoombaStompedState(Goomba goomba)
        {
            this.goomba            = goomba;
            goomba.EnemyCollidable = true;
            sprite         = EnemySpriteFactory.Instance.CreateGoombaStompedSprite();
            Width          = sprite.Width;
            Height         = sprite.Height;
            disappearTimer = Utils.Instance.EnemyTimeToDisappear;

            goomba.Physics.ResetMotion();
            goomba.Physics.Locked = true;
        }
 public void OnTriggerEnter2D(Collider2D collision)
 {
     try
     {
         if (collision.gameObject.CompareTag("Finish"))
         {
             Goomba goomba = gameObject.GetComponent <Goomba>();
             goomba.SendMessage("NotifyAll");
             StartCoroutine(lose());
         }
     }
     catch { }
 }
예제 #27
0
        public GoombaDeathState(Goomba goomba, GameObject gameObject)
        {
            Systems.Events.TheInstance.GoombaDied();
            this.goomba = goomba;

            if (gameObject is Mario)
            {
                this.goomba.XSpeed = 0.0f;

                if (!((Mario)gameObject).IsInvincible())
                {
                    this.goomba.GetGravity.Disable();
                    this.goomba.Sprite = this.goomba.SpriteFactory.CreateProduct(EnemyTypes.GoombaDeath);
                }
                else
                {
                    this.goomba.YSpeed = -2.0f;
                    this.goomba.Sprite = this.goomba.SpriteFactory.CreateProduct(EnemyTypes.GoombaFireBallDeath);
                }
            }
            else if (gameObject is Sword)
            {
                this.goomba.XSpeed = 0.0f;
                this.goomba.GetGravity.Disable();
                this.goomba.Sprite = this.goomba.SpriteFactory.CreateProduct(EnemyTypes.GoombaDeath);
            }
            else if (gameObject is FireBall)
            {
                if ((gameObject).PositionInGame.X > this.goomba.PositionInGame.X)
                {
                    this.goomba.XSpeed = -1.0f;
                }
                else
                {
                    this.goomba.XSpeed = 1.0f;
                }
                this.goomba.YSpeed = -2.0f;

                this.goomba.Sprite = this.goomba.SpriteFactory.CreateProduct(EnemyTypes.GoombaFireBallDeath);
            }
            else
            {
                this.goomba.XSpeed = 0.0f;
                this.goomba.YSpeed = -2.0f;
                this.goomba.Sprite = this.goomba.SpriteFactory.CreateProduct(EnemyTypes.GoombaFireBallDeath);
            }

            this.goomba.isGoombaDead = true;
            this.goomba.IsCollidable = false;
        }
 public void MarioGoombaBottomCollision()
 {
     TestGame = new MarioGame();
     TestWorld = TestGame.World;
     Content = TestGame.Content;
     TestMario = TestGame.World.Mario;
     TestGoomba = TestGame.World.Goomba;
     TestCommand = new MarioUpCommand(TestGame);
     TestMario.PassCommand(TestCommand);
     //Check if Mario is dead
     //Assert.AreEqual(true, TestMario.SpriteState.IsDead());
     //Check if Goomba is dead
     //Assert.AreEqual(GoombaSprite, TestGoomba.SpriteState);
 }
예제 #29
0
        public void TestEnemyOnLeftOfBlockCollisionDetection()
        {
            Goomba     enemy = new Goomba(new Vector2(100, 100));
            FloorBlock block = new FloorBlock(new Vector2(120, 100));

            Rectangle enemyRect = enemy.GetRectangle();
            Rectangle blockRect = block.GetRectangle();

            GeneralCollisionDetector generalDetector = new GeneralCollisionDetector();

            Game1.Side collisionType = generalDetector.DetermineCollision(enemyRect, blockRect);

            Assert.AreEqual(collisionType, Game1.Side.Right);
        }
예제 #30
0
        public void TestMarioOnBottomOfEnemyCollisionDetector()
        {
            Mario  mario = new Mario(new Vector2(100, 115));
            Goomba enemy = new Goomba(new Vector2(100, 100));

            Rectangle marioRect = mario.GetRectangle();
            Rectangle enemyRect = enemy.GetRectangle();

            GeneralCollisionDetector generalDetector = new GeneralCollisionDetector();

            Game1.Side collisionType = generalDetector.DetermineCollision(marioRect, enemyRect);
            Game1.Side expectedType  = Game1.Side.Top;
            Assert.AreEqual(expectedType, collisionType);
        }
예제 #31
0
        public GoombaCorpse(Goomba g)
            : base()
        {
            distance = Entity.DISTANCE_CORPSE;
            width    = Block.BLOCK_WIDTH;
            height   = Block.BLOCK_HEIGHT;

            texture = Textures.texture_goomba_dead;

            DefaultNewtonController controller = new DefaultNewtonController(this, GOOMBA_CORPSE_FRICION);

            controller.movementDelta = g.GetMovement();
            AddController(controller);
        }
예제 #32
0
        public void HasBattleEndedAfterAllEnemiesKilled()
        {
            var goomba    = new Goomba();
            var encounter = new Encounter(goomba, new SpikedGoomba());
            var battle    = new Battle.Battle(new List <Hero> {
                mario
            }, encounter);

            battle.Start();
            Assert.IsTrue(battle.IsStarted());
            //Can you kill a goomba if the battle has started??
            battle.Enemies.ForEach(enemy => enemy.Kill());
            Assert.IsTrue(battle.IsEnded());
            Assert.IsFalse(battle.IsStarted());
        }
예제 #33
0
        public void TestMarioOnBottomOfEnemyCollisionHandling()
        {
            Mario  mario = new Mario(new Vector2(100, 115));
            Goomba enemy = new Goomba(new Vector2(100, 100));

            Rectangle marioRect = mario.GetRectangle();
            Rectangle enemyRect = enemy.GetRectangle();

            Game1.Side collisionType = Game1.Side.Top;
            MarioEnemyCollisionHandler.HandleCollision(mario, enemy, collisionType);
            bool actualValue   = mario.IsDying();
            bool expectedValue = true;

            Assert.AreEqual(expectedValue, actualValue);
        }
예제 #34
0
        public static void HandleGoombaCollision(Goomba goomba, IBlock block, CollisionSide side)
        {
            Physics.GeneralPhysics.RepelObject(block, goomba, side);

            if (block.BlockPhysics.BlockBumped)
            {
                goomba.BeFlipped();
                SoundFactory.Instance.PlayKickEnemySound();
            }
            else
            {
                if (IsHorizontalCollision(side))
                {
                    goomba.ChangeDirection(side);
                }
            }
        }
예제 #35
0
        public void TestEnemyOnRightOfBlockCollisionHandling()
        {
            IEnemy     enemy       = new Goomba(new Vector2(110, 100));
            Goomba     staticEnemy = new Goomba(new Vector2(100, 100));
            FloorBlock block       = new FloorBlock(new Vector2(100, 100));

            Rectangle enemyRect = enemy.GetRectangle();
            Rectangle blockRect = block.GetRectangle();

            Game1.Side collisionType = Game1.Side.Left;
            EnemyBlockCollisionHandler.HandleCollision(enemy, block, collisionType);

            IEnemyState enemyState    = enemy.GetState();
            IEnemyState expectedState = new GoombaLeftMovingState(staticEnemy);

            Assert.AreEqual(enemyState.ToString(), expectedState.ToString());
        }
        public void SmallMarioGoombaBottomSideCollisionTest()
        {
            IMario testMario = new MarioInstance(game);
            testMario.VectorCoordinates = new Vector2(0, 14);
            IMario expectedMario = new MarioInstance(game);
            expectedMario.VectorCoordinates = new Vector2(0, 16);
            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 DeadMarioState;
            bool expectedState = expectedMario.MarioState is DeadMarioState;
            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;
        }
        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);
        }