public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            foreach (IBackgroundItem backgroundItem in BackgroundItems)
            {
                if (IsOnScreen(backgroundItem.Position.X))
                {
                    backgroundItem.Draw(spriteBatch, gameTime);
                }
            }

            if (IsOnScreen(Castle.Position.X))
            {
                Castle.Draw(spriteBatch, gameTime);
            }

            Mario.Instance.Draw(spriteBatch, gameTime);

            foreach (Item coin in Coins)
            {
                if (IsOnScreen(coin.Position.X))
                {
                    coin.Draw(spriteBatch, gameTime);
                }
            }

            foreach (Enemy enemy in Enemies)
            {
                if (IsOnScreen(enemy.Position.X))
                {
                    enemy.Draw(spriteBatch, gameTime);
                }
            }

            foreach (IStaticObject staticObject in StaticObjects)
            {
                staticObject.Draw(spriteBatch, gameTime);
            }

            foreach (Block block in Blocks)
            {
                block.Draw(spriteBatch, gameTime);
            }

            Flag.Draw(spriteBatch, gameTime);
        }
        private void BuildLevel(List <string[]> levelData)
        {
            // iterate through lines
            for (int i = 0; i < levelData.Count(); i++)
            {
                switch (levelData[i][0])
                {
                case "00":
                    // mario
                    Mario.Instance.PlayableObjectState = new SmallRightIdleMario(Mario.Instance);
                    Mario.Instance.Position            = new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize);
                    break;

                case "01":
                    // floor tiles
                    StaticObjects.Add(new FloorTile(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), new Vector2(StringToInt(i, 3), StringToInt(i, 4)), levelData[i][5]));
                    break;

                case "02":
                    // blocks
                    Blocks.Add(new Block(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), levelData[i][3], levelData[i][4]));
                    break;

                case "03":
                    // floating coins
                    Coins.Add(new Item(new Vector2((StringToInt(i, 1) * levelCellSize) + (levelCellSize / 4), StringToInt(i, 2) * levelCellSize), "FloatingCoin"));
                    break;

                case "04":
                    // pipes
                    Pipes.Add(new Pipe(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3), Convert.ToBoolean(levelData[i][4]), levelData[i][5]));
                    break;

                case "05":
                    // enemies
                    Enemies.Add(new Enemy(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize - 10), levelData[i][3]));
                    break;

                case "06":
                    // hills
                    BackgroundItems.Add(new Hill(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3)));
                    break;

                case "07":
                    // bushes
                    BackgroundItems.Add(new Bush(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3)));
                    break;

                case "08":
                    // clouds
                    BackgroundItems.Add(new Cloud(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3)));
                    break;

                case "09":
                    // castle
                    Castle = new Castle(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize));
                    break;

                case "10":
                    // flag pole
                    Flagpoles.Add(new Flagpole(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), levelCellSize));
                    break;

                case "11":
                    // check point
                    Checkpoints.Add(new CheckPoint(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize)));
                    break;

                case "12":
                    // coin room
                    CoinRoomPosition = new Vector2(StringToInt(i, 1) * levelCellSize + (levelCellSize / 8), StringToInt(i, 2) * levelCellSize);
                    break;
                }
            }

            DynamicObjects.Add(Mario.Instance);

            foreach (Block block in Blocks)
            {
                DynamicObjects.Add(block);
                DynamicObjects.Add(block.Item); // Add items in each block too.
            }

            foreach (Item coin in Coins)
            {
                DynamicObjects.Add(coin);
            }

            foreach (Enemy enemy in Enemies)
            {
                // Added such that the Koopa spawns in a correct position before any updates are made, otherwise he spawns in the floor to start.
                if (enemy.EnemyState.ToString() == "SuperMario.EnemyStates.LeftWalkingKoopa" || enemy.EnemyState.ToString() == "SuperMario.EnemyStates.RightWalkingKoopa")
                {
                    enemy.Position = new Vector2(enemy.Position.X, enemy.Position.Y - GameValues.KoopaPositionOffset);
                }
                DynamicObjects.Add(enemy);
            }

            foreach (Pipe pipe in Pipes)
            {
                StaticObjects.Add(pipe);
            }

            foreach (Flagpole flagpole in Flagpoles)
            {
                StaticObjects.Add(flagpole);
            }

            if (Flagpoles.Count > 0)
            {
                Flag.Position = new Vector2(Flagpoles[0].CollisionRectangle.X - GameValues.FlagPositionOffsetVector.X, Flagpoles[0].CollisionRectangle.Y + GameValues.FlagPositionOffsetVector.Y);
            }
        }
        private void BuildLevel(List<string[]> levelData)
        {
            // iterate through lines
            for (int i = 0; i < levelData.Count(); i++)
            {
                switch (levelData[i][0])
                {
                    case "00":
                        // mario
                        Mario.Instance.PlayableObjectState = new SmallRightIdleMario(Mario.Instance);
                        Mario.Instance.Position = new Vector2(StringToInt(i,1) * levelCellSize, StringToInt(i,2) * levelCellSize);
                    break;
                    case "01":
                        // floor tiles
                        StaticObjects.Add(new FloorTile(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), new Vector2(StringToInt(i, 3), StringToInt(i, 4)), levelData[i][5]));
                    break;
                    case "02":
                        // blocks
                        Blocks.Add(new Block(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), levelData[i][3], levelData[i][4]));
                    break;
                    case "03":
                        // floating coins
                        Coins.Add(new Item(new Vector2((StringToInt(i, 1) * levelCellSize) + (levelCellSize/4), StringToInt(i, 2) * levelCellSize), "FloatingCoin"));
                    break;
                    case "04":
                        // pipes
                        Pipes.Add(new Pipe(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3), Convert.ToBoolean(levelData[i][4]), levelData[i][5]));
                    break;
                    case "05":
                        // enemies
                        Enemies.Add(new Enemy(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize - 10), levelData[i][3]));
                    break;
                    case "06":
                        // hills
                        BackgroundItems.Add(new Hill(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3)));
                    break;
                    case "07":
                        // bushes
                        BackgroundItems.Add(new Bush(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3)));
                    break;
                    case "08":
                        // clouds
                        BackgroundItems.Add(new Cloud(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3)));
                    break;
                    case "09":
                        // castle
                        Castle = new Castle(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i,2) * levelCellSize));
                    break;
                    case "10":
                        // flag pole
                        Flagpoles.Add(new Flagpole(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), levelCellSize));
                    break;
                    case "11":
                        // check point
                        Checkpoints.Add(new CheckPoint(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize)));
                    break;
                    case "12":
                        // coin room
                        CoinRoomPosition = new Vector2(StringToInt(i, 1) * levelCellSize + (levelCellSize/8), StringToInt(i, 2) * levelCellSize);
                    break;
                }
            }

            DynamicObjects.Add(Mario.Instance);

            foreach (Block block in Blocks)
            {
                DynamicObjects.Add(block);
                DynamicObjects.Add(block.Item); // Add items in each block too.
            }

            foreach (Item coin in Coins)
            {
                DynamicObjects.Add(coin);
            }

            foreach (Enemy enemy in Enemies)
            {
                // Added such that the Koopa spawns in a correct position before any updates are made, otherwise he spawns in the floor to start.
                if (enemy.EnemyState.ToString() == "SuperMario.EnemyStates.LeftWalkingKoopa" || enemy.EnemyState.ToString() == "SuperMario.EnemyStates.RightWalkingKoopa")
                {
                    enemy.Position = new Vector2(enemy.Position.X, enemy.Position.Y - GameValues.KoopaPositionOffset);
                }
                DynamicObjects.Add(enemy);
            }

            foreach (Pipe pipe in Pipes)
            {
                StaticObjects.Add(pipe);
            }

            foreach (Flagpole flagpole in Flagpoles)
            {
                StaticObjects.Add(flagpole);
            }

            if (Flagpoles.Count > 0)
            {
                Flag.Position = new Vector2(Flagpoles[0].CollisionRectangle.X - GameValues.FlagPositionOffsetVector.X, Flagpoles[0].CollisionRectangle.Y + GameValues.FlagPositionOffsetVector.Y);
            }
        }