private static void LoadLevel(XmlReader reader)
        {
            Random         random       = new Random();
            string         objectType   = "";
            string         objectName   = "";
            string         location     = "";
            bool           typeFlag     = false;
            bool           nameFlag     = false;
            bool           locationFlag = false;
            IList <IBlock> blockList    = new List <IBlock>();
            IList <IEnemy> enemyList    = new List <IEnemy>();
            IList <IItem>  itemList     = new List <IItem>();

            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    switch (reader.Name.ToString())
                    {
                    case "ObjectType":
                        objectType = reader.ReadString();
                        typeFlag   = true;
                        break;

                    case "ObjectName":
                        objectName = reader.ReadString();
                        nameFlag   = true;
                        break;

                    case "Location":
                        location     = reader.ReadString();
                        locationFlag = true;
                        break;
                    }

                    if (typeFlag && nameFlag && locationFlag)
                    {
                        switch (objectType)
                        {
                        case "Player":
                            string[] coordinates = location.Split(' ');
                            Mario.Instance.ConditionState = new SmallMarioState(Mario.Instance);
                            Mario.Instance.Location       = new Vector2(Int32.Parse(coordinates[0]), Int32.Parse(coordinates[1]));
                            break;

                        case "Block":
                            switch (objectName)
                            {
                            case "HiddenBlock":
                                string[] blockCoordinates = location.Split(' ');
                                IBlock   block            = new HiddenBlock();
                                block.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "HiddenBlockEmpty":
                                blockCoordinates = location.Split(' ');
                                block            = new HiddenBlockEmpty();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "HiddenBlockCoin":
                                blockCoordinates = location.Split(' ');
                                block            = new HiddenBlockCoin();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "HiddenBlockStar":
                                blockCoordinates = location.Split(' ');
                                block            = new HiddenBlockStar();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "BrickBlock":
                                blockCoordinates = location.Split(' ');
                                block            = new BrickBlock();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "BrickBlockEmpty":
                                blockCoordinates = location.Split(' ');
                                block            = new BrickBlockEmpty();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "ItemBrick":
                                blockCoordinates = location.Split(' ');
                                block            = new BrickBlockWithItem();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "ItemBrickCoin":
                                blockCoordinates = location.Split(' ');
                                block            = new BrickBlockWithCoin();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "ItemBrickStar":
                                blockCoordinates = location.Split(' ');
                                block            = new BrickBlockWithStar();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "QuestionBlock":
                                blockCoordinates = location.Split(' ');
                                block            = new QuestionBlock();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "QuestionBlockEmpty":
                                blockCoordinates = location.Split(' ');
                                block            = new QuestionBlockEmpty();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "QuestionBlockStar":
                                blockCoordinates = location.Split(' ');
                                block            = new QuestionBlockStar();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "QuestionBlockCoin":
                                blockCoordinates = location.Split(' ');
                                block            = new QuestionBlockCoin();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "UnbreakableBlock":
                                blockCoordinates = location.Split(' ');
                                block            = new UnbreakableBlock();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "UsedBlock":
                                blockCoordinates = location.Split(' ');
                                block            = new UsedBlock();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "GroundBlock":
                                blockCoordinates = location.Split(' ');
                                block            = new GroundBlock();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "Pipe":
                                blockCoordinates = location.Split(' ');
                                block            = new Pipe();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "PipeBottom":
                                blockCoordinates = location.Split(' ');
                                block            = new PipeBottom();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;

                            case "WarpPipe":
                                blockCoordinates = location.Split(' ');
                                WarpPipe pipe = new WarpPipe();
                                pipe.Location = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                switch (pipe.Location.X)
                                {
                                case 1760:
                                    pipe.WarpDestination = new Vector2(8000, 384);
                                    break;

                                case 8736:
                                    pipe.WarpDestination = new Vector2(2080, 352);
                                    break;
                                }
                                blockList.Add((IBlock)pipe);
                                break;

                            case "FlagPole":
                                blockCoordinates = location.Split(' ');
                                block            = new FlagPole();
                                block.Location   = new Vector2(Int32.Parse(blockCoordinates[0]), Int32.Parse(blockCoordinates[1]));
                                blockList.Add(block);
                                break;
                            }
                            break;

                        case "Enemy":
                            switch (objectName)
                            {
                            case "Goomba":
                                string[] enemyCoordinates = location.Split(' ');
                                IEnemy   enemy            = new Goomba();
                                enemy.RowId    = random.Next(0, 160);
                                enemy.Location = new Vector2(Int32.Parse(enemyCoordinates[0]), Int32.Parse(enemyCoordinates[1]));
                                enemyList.Add(enemy);
                                break;

                            case "Koopa":
                                enemyCoordinates = location.Split(' ');
                                enemy            = new Koopa();
                                enemy.RowId      = random.Next(0, 160);
                                enemy.Location   = new Vector2(Int32.Parse(enemyCoordinates[0]), Int32.Parse(enemyCoordinates[1]));
                                enemyList.Add(enemy);
                                break;
                            }
                            break;

                        case "Item":
                            switch (objectName)
                            {
                            case "Coin":
                                string[] itemCoordinates = location.Split(' ');
                                IItem    item            = new Coin();
                                item.Location = new Vector2(Int32.Parse(itemCoordinates[0]), Int32.Parse(itemCoordinates[1]));
                                itemList.Add(item);
                                break;

                            case "FireFlower":
                                itemCoordinates = location.Split(' ');
                                item            = new FireFlower();
                                item.Location   = new Vector2(Int32.Parse(itemCoordinates[0]), Int32.Parse(itemCoordinates[1]));
                                itemList.Add(item);
                                break;

                            case "OneUpMush":
                                itemCoordinates = location.Split(' ');
                                item            = new OneUpMushroom();
                                item.Location   = new Vector2(Int32.Parse(itemCoordinates[0]), Int32.Parse(itemCoordinates[1]));
                                itemList.Add(item);
                                break;

                            case "SuperMush":
                                itemCoordinates = location.Split(' ');
                                item            = new SuperMushroom();
                                item.Location   = new Vector2(Int32.Parse(itemCoordinates[0]), Int32.Parse(itemCoordinates[1]));
                                itemList.Add(item);
                                break;

                            case "Star":
                                itemCoordinates = location.Split(' ');
                                item            = new Star();
                                item.Location   = new Vector2(Int32.Parse(itemCoordinates[0]), Int32.Parse(itemCoordinates[1]));
                                itemList.Add(item);
                                break;
                            }
                            break;
                        }
                        typeFlag     = false;
                        nameFlag     = false;
                        locationFlag = false;
                    }
                }
            }
            PlayerLevel.Instance.BlockArray = blockList;
            PlayerLevel.Instance.EnemyArray = enemyList;
            PlayerLevel.Instance.ItemArray  = itemList;
        }
    //---------------------------------------------------------------------------------------------------------------------
    //---------------------------------------------------------------------------------------------------------------------

    #region 3) BUILD BLOCKS
    void SetLevelBlocks(List <GroundTileScript> gtList, GameObject _blockPrefab, GameObject parentTransform)
    {
        // Sets the blocks based on the hasBlockOnIt bool for each tile in groundCells.
        Vector3 yOffset = new Vector3(0, 2.1f, 0);  // based on the tile prefab's half height. Jerry-rigged here for the time being.

        foreach (GroundTileScript gt in gtList)
        {
            Vector3 spawnPos = gt.transform.position + yOffset;
            if (gt.tileReference.hasBlockOnIt)
            {
                GameObject       dataBlock   = GameObject.Instantiate(_blockPrefab, spawnPos, Quaternion.identity, parentTransform.transform);
                LevelBlockScript dBComponent = dataBlock.AddComponent <LevelBlockScript>();


                switch (gt.tileReference.type)
                {
                case GroundTile.GroundType.CLEAR:
                    BasicBlock basicMinableDB = new BasicBlock(gt, true);
                    dBComponent.levelBlockReference = basicMinableDB;
                    dBComponent.levelBlockReference.dBlockRenderer = dataBlock.gameObject.GetComponent <MeshRenderer>();
                    dBComponent.levelBlockReference.dBSpriterndr   = dataBlock.gameObject.GetComponentInChildren <SpriteRenderer>();
                    dBComponent.levelBlockReference.dBHoverandSel  = dataBlock.gameObject.GetComponentInChildren <HoverAndSelection>();
                    dBComponent.levelBlockReference.dBHoverandSel.isInterractable = true;
                    dataBlock.AddComponent <Mineable>();
                    dataBlock.AddComponent <Explodable>();
                    break;

                case GroundTile.GroundType.ROUGH:
                    ToughBlock toughMinableDB = new ToughBlock(gt, true);
                    dBComponent.levelBlockReference = toughMinableDB;
                    dBComponent.levelBlockReference.dBlockRenderer = dataBlock.gameObject.GetComponent <MeshRenderer>();
                    dBComponent.levelBlockReference.dBSpriterndr   = dataBlock.gameObject.GetComponentInChildren <SpriteRenderer>();
                    dBComponent.levelBlockReference.dBHoverandSel  = dataBlock.gameObject.GetComponentInChildren <HoverAndSelection>();
                    dBComponent.levelBlockReference.dBHoverandSel.isInterractable = true;
                    dataBlock.AddComponent <Mineable>();
                    dataBlock.AddComponent <Explodable>();
                    dataBlock.AddComponent <Tough>();
                    break;

                case GroundTile.GroundType.IMPASSABLE:
                    UnbreakableBlock unbreakableDB = new UnbreakableBlock(gt, false);
                    dBComponent.levelBlockReference = unbreakableDB;
                    dBComponent.levelBlockReference.dBlockRenderer = dataBlock.gameObject.GetComponent <MeshRenderer>();
                    dBComponent.levelBlockReference.dBSpriterndr   = dataBlock.gameObject.GetComponentInChildren <SpriteRenderer>();
                    dBComponent.levelBlockReference.dBHoverandSel  = dataBlock.gameObject.GetComponentInChildren <HoverAndSelection>();
                    dBComponent.levelBlockReference.dBHoverandSel.isInterractable = false;
                    break;

                case GroundTile.GroundType.HAZARD:
                    CorruptBlock corruptMinableDB = new CorruptBlock(gt, true);
                    dBComponent.levelBlockReference = corruptMinableDB;
                    dBComponent.levelBlockReference.dBlockRenderer = dataBlock.gameObject.GetComponent <MeshRenderer>();
                    dBComponent.levelBlockReference.dBSpriterndr   = dataBlock.gameObject.GetComponentInChildren <SpriteRenderer>();
                    dBComponent.levelBlockReference.dBHoverandSel  = dataBlock.gameObject.GetComponentInChildren <HoverAndSelection>();
                    dBComponent.levelBlockReference.dBHoverandSel.isInterractable = true;
                    dataBlock.AddComponent <Mineable>();
                    dataBlock.AddComponent <CleanMeImCorrupted>();
                    break;

                default:
                    BasicBlock defaultBasicBlock = new BasicBlock(gt, true);
                    dBComponent.levelBlockReference = defaultBasicBlock;
                    dBComponent.levelBlockReference.dBlockRenderer = dataBlock.gameObject.GetComponent <MeshRenderer>();
                    dBComponent.levelBlockReference.dBSpriterndr   = dataBlock.gameObject.GetComponentInChildren <SpriteRenderer>();
                    dBComponent.levelBlockReference.dBHoverandSel  = dataBlock.gameObject.GetComponentInChildren <HoverAndSelection>();
                    dBComponent.levelBlockReference.dBHoverandSel.isInterractable = true;
                    dataBlock.AddComponent <Mineable>();
                    dataBlock.AddComponent <Explodable>();
                    Debug.Log("No usable info found, using default block state");
                    break;
                }
                dBComponent.levelBlockReference.LoadPropertiesDB();

                dBComponent.levelBlockReference.dBHoverandSel.isInterractable = dBComponent.levelBlockReference.isBreakable;
                dBComponent.levelBlockReference.dBHoverandSel.hsSprite        = dBComponent.levelBlockReference.dBSpriterndr.sprite;
                dBComponent.levelBlockReference.dBHoverandSel.SetSpriteRef();

                dataBlock.name = "Block ID: " + dBComponent.levelBlockReference.dBlockID + " | Coords z/x: " + dBComponent.levelBlockReference.dBlock_YorZ + " ; " + dBComponent.levelBlockReference.dBlock_X;
            }
            else
            {
                continue;
            }
        }
    }