Пример #1
0
        public static FlxTilemap createCave()
        {
            FlxCaveGenerator cav = new FlxCaveGenerator((int)Registry.levelSize.X, (int)Registry.levelSize.Y, 0.55f, 30);
            
            int[,] matr = cav.generateCaveLevel(null, null, null, null, null, null, null, null);

            matr = cav.editRectangle(matr, 0, (int)Registry.levelSize.Y / 2, (int)Registry.levelSize.X, 4, 1);
            matr = cav.editRectangle(matr, (int)Registry.levelSize.X / 2, 0, 4, (int)Registry.levelSize.Y, 1);

            matr = cav.grow(matr);

            matr = cav.editRectangle(matr, 0, 0, (int)Registry.levelSize.X, 1, 0);
            matr = cav.editRectangle(matr, 0, 0, 1, (int)Registry.levelSize.Y, 0);

            matr = cav.editRectangle(matr, 0, (int)Registry.levelSize.Y-1, (int)Registry.levelSize.X, 1, 0);
            matr = cav.editRectangle(matr, (int)Registry.levelSize.X-1, 0, 1, (int)Registry.levelSize.Y, 0);

            string newMap = cav.convertMultiArrayToString(matr);

            FlxTilemap tiles = new FlxTilemap();
            // Remap guide before loading map
            tiles.remapGuide = Registry.createAltTileRemap();
            tiles.auto = FlxTilemap.REMAPALT;
            tiles.loadMap(newMap, FlxG.Content.Load<Texture2D>("tiles/oryx_16bit_fantasy_world_trans"), Registry.tileSize, Registry.tileSize);

            tiles.setScrollFactors(1, 1);

            Registry.levelAsTilemap = tiles;

            return tiles;

        }
Пример #2
0
        public override void OnMouseRightDown(System.Drawing.Point location)
        {
            if (!drawing)
            {
                drawing  = true;
                drawMode = true;

                int sizeX = LayerEditor.Layer.GridCellsX;
                int sizeY = LayerEditor.Layer.GridCellsY;

                FlxCaveGenerator cave = new FlxCaveGenerator(LayerEditor.Layer.GridCellsX, LayerEditor.Layer.GridCellsY);
                cave.genInitMatrix(LayerEditor.Layer.GridCellsX, LayerEditor.Layer.GridCellsY);

                int[,] level = cave.generateCaveLevel();

                for (int i = 0; i < sizeX; i++)
                {
                    for (int j = 0; j < sizeY; j++)
                    {
                        System.Drawing.Point p = new System.Drawing.Point(i * LayerEditor.Layer.Definition.Grid.Width, j * LayerEditor.Layer.Definition.Grid.Height);

                        setCell(p, true);

                        if (level[j, i] == 1)
                        {
                            setCell(p, false);
                        }
                        else
                        {
                            setCell(p, true);
                        }
                    }
                }
            }
        }
Пример #3
0
        public void autoTile(int Index)
        {
            int totalTiles = LayerEditor.Layer.TileCellsX * LayerEditor.Layer.TileCellsY;

            if (_data[Index] == 0)
            {
                return;
            }
            _data[Index] = 0;
            if ((Index - widthInTiles < 0) || (_data[Index - widthInTiles] > 0))                //UP
            {
                _data[Index] += 1;
            }
            if ((Index % widthInTiles >= widthInTiles - 1) || (_data[Index + 1] > 0))           //RIGHT
            {
                _data[Index] += 2;
            }
            if ((Index + widthInTiles >= totalTiles) || (_data[Index + widthInTiles] > 0)) //DOWN
            {
                _data[Index] += 4;
            }
            if ((Index % widthInTiles <= 0) || (_data[Index - 1] > 0))                                  //LEFT
            {
                _data[Index] += 8;
            }

            if ((auto == ALT) && (_data[Index] == 15))  //The alternate algo checks for interior corners
            {
                if ((Index % widthInTiles > 0) && (Index + widthInTiles < totalTiles) && (_data[Index + widthInTiles - 1] <= 0))
                {
                    _data[Index] = 1;           //BOTTOM LEFT OPEN
                }
                if ((Index % widthInTiles > 0) && (Index - widthInTiles >= 0) && (_data[Index - widthInTiles - 1] <= 0))
                {
                    _data[Index] = 2;           //TOP LEFT OPEN
                }
                if ((Index % widthInTiles < widthInTiles - 1) && (Index - widthInTiles >= 0) && (_data[Index - widthInTiles + 1] <= 0))
                {
                    _data[Index] = 4;           //TOP RIGHT OPEN
                }
                if ((Index % widthInTiles < widthInTiles - 1) && (Index + widthInTiles < totalTiles) && (_data[Index + widthInTiles + 1] <= 0))
                {
                    _data[Index] = 8;           //BOTTOM RIGHT OPEN
                }
            }

            _data[Index] += 1;


            //extra part for if you have extra tiles.

            int _extraMiddleTiles = LayerEditor.Layer.Tileset.TilesAcross;

            if (_extraMiddleTiles >= 16 && _data[Index] == 16)
            {
                _data[Index] += ((int)(FlxCaveGenerator.random(16, _extraMiddleTiles + 1)) - 16);
            }
        }
Пример #4
0
        public void makeCave(float Scroll, Color Col)
        {
            // make a new cave of tiles 50x40;
            FlxCaveGenerator cav = new FlxCaveGenerator(100, 100, 0.48f, 1);

            //Create a matrix based on these parameters.
            int[,] matr = cav.generateCaveLevel(3, 0, 2, 0, 1, 1, 1, 1);

            //convert the array to a comma separated string
            string newMap = cav.convertMultiArrayToString(matr);

            //Create a tilemap and assign the cave map.
            tiles      = new FlxTilemap();
            tiles.auto = FlxTilemap.AUTO;
            tiles.loadMap(newMap, FlxG.Content.Load <Texture2D>("flixel/autotiles_16x16"), 16, 16);
            tiles.setScrollFactors(Scroll, Scroll);
            tiles.color = Col;

            add(tiles);
        }
Пример #5
0
        public override void OnMouseLeftDown(System.Drawing.Point location)
        {
            int sizeX = LayerEditor.Layer.GridCellsX;
            int sizeY = LayerEditor.Layer.GridCellsY;

            FlxCaveGenerator cave = new FlxCaveGenerator(LayerEditor.Layer.GridCellsX, LayerEditor.Layer.GridCellsY);

            cave.genInitMatrix(LayerEditor.Layer.GridCellsX, LayerEditor.Layer.GridCellsY);
            int[,] level = cave.generateCaveLevel();

            for (int y = 0; y < sizeY; y++)
            {
                for (int x = 0; x < sizeX; x++)
                {
                    level[y, x] = Convert.ToInt32(LayerEditor.Layer.Grid[x, y]);
                }
            }

            level = cave.smoothLevel(level);

            for (int y = 0; y < sizeY; y++)
            {
                for (int x = 0; x < sizeX; x++)
                {
                    System.Drawing.Point p = new System.Drawing.Point(x * LayerEditor.Layer.Definition.Grid.Width, y * LayerEditor.Layer.Definition.Grid.Height);

                    setCell(p, false);

                    if (level[y, x] == 1)
                    {
                        setCell(p, true);
                    }
                    else
                    {
                        setCell(p, false);
                    }
                }
            }
        }
Пример #6
0
        private void buildCave()
        {
            // make a new cave of tiles 50x40;
            cav = new FlxCaveGenerator(50, 50, 0.55f, 30);

            //Create a matrix based on these parameters.
            matr = cav.generateCaveLevel(null, null, null, null, null, null, new int[] { 0, 49 }, new int[] { 0, 49 });
            matr = cav.grow(matr);

            foreach (Dictionary<string, string> item in Registry.boxes)
            {
                Console.WriteLine("{0} {1} {2} {3} {4} ", item["Name"], item["x"], item["y"], item["width"], item["height"]);

                if (item["Name"] == "TileCrate")
                {

                    createTileblock(item);

                    matr = cav.editRectangle(matr, Convert.ToInt32(item["x"]) / 16, Convert.ToInt32(item["y"]) / 16, Convert.ToInt32(item["width"]) / 16, Convert.ToInt32(item["height"]) / 16, 0);
                }
            }
            //foreach (Dictionary<string, string> item in p)
            //{
            //    if (item["Name"]=="Crate")
            //        matr = cav.editRectangle(matr, Convert.ToInt32(item["x"]) / 16, Convert.ToInt32(item["y"]) / 16 , 4, 4, 0);
            //}

            string newMap = cav.convertMultiArrayToString(matr);

            //Create a tilemap and assign the cave map.
            tiles = new FlxTilemap();
            tiles.auto = FlxTilemap.REMAPALT;
            tiles.loadMap(newMap, FlxG.Content.Load<Texture2D>("tiles/oryx_16bit_fantasy_world_trans"), 24, 24);
            tiles.setScrollFactors(1, 1);
            add(tiles);

            Registry.levelAsTilemap = tiles;

            for (int i = 0; i < 55; i++)
            {
                int rx = FlxU.randomInt(1, 35);
                int ry = FlxU.randomInt(1, 35);

                int rz = tiles.getTile(rx, ry);

                if (rz == 292)
                {
                    Dictionary<string, string> x = new Dictionary<string, string>();
                    x.Add("Name", "PickUp");
                    x.Add("x", (rx * 24).ToString());
                    x.Add("y", (ry * 24).ToString());

                    createSprite(x);
                }

            }

            for (int i = 0; i < 1; i++)
            {
                int rx = FlxU.randomInt(1, 35);
                int ry = FlxU.randomInt(1, 35);

                int rz = tiles.getTile(rx, ry);

                if (rz == 292)
                {
                    Dictionary<string, string> x = new Dictionary<string, string>();
                    x.Add("Name", "Character");
                    x.Add("x", (rx * 24).ToString());
                    x.Add("y", ((ry * 24) - 2).ToString());

                    createSprite(x);
                }
            }
        }
Пример #7
0
        public void addDecorations()
        {
            int sizeX = LayerEditor.Layer.TileCellsX;
            int sizeY = LayerEditor.Layer.TileCellsY;

            float chance = Convert.ToSingle(Ogmo.CaveWindow.chanceOfDecoration.Text);

            for (int y = 0; y < sizeY; y++)
            {
                for (int x = 0; x < sizeX; x++)
                {
                    // up

                    if (chance < FlxCaveGenerator.random())
                    {
                        if (LayerEditor.Layer.Tiles[x, y] == 14 && y >= 1)
                        {
                            System.Drawing.Point p = new System.Drawing.Point(x * LayerEditor.Layer.Definition.Grid.Width, (y * LayerEditor.Layer.Definition.Grid.Height) - LayerEditor.Layer.Definition.Grid.Height);
                            SetCaveTile(p, (int)FlxCaveGenerator.random(LayerEditor.Layer.Tileset.TilesAcross, LayerEditor.Layer.Tileset.TilesAcross * 2));
                        }

                        //down
                        if (LayerEditor.Layer.Tiles[x, y] == 11 && y < LayerEditor.Layer.TileCellsY)
                        {
                            System.Drawing.Point p = new System.Drawing.Point(x * LayerEditor.Layer.Definition.Grid.Width, (y * LayerEditor.Layer.Definition.Grid.Height) + LayerEditor.Layer.Definition.Grid.Height);
                            SetCaveTile(p, (int)FlxCaveGenerator.random(LayerEditor.Layer.Tileset.TilesAcross * 2, LayerEditor.Layer.Tileset.TilesAcross * 3));
                        }

                        if ((LayerEditor.Layer.Tiles[x, y] == 7) && x >= 1)
                        {
                            System.Drawing.Point p = new System.Drawing.Point((x * LayerEditor.Layer.Definition.Grid.Width) - LayerEditor.Layer.Definition.Grid.Width, (y * LayerEditor.Layer.Definition.Grid.Height));
                            SetCaveTile(p, (int)FlxCaveGenerator.random(LayerEditor.Layer.Tileset.TilesAcross * 4, LayerEditor.Layer.Tileset.TilesAcross * 5));
                        }


                        if ((LayerEditor.Layer.Tiles[x, y] == 13) && y < LayerEditor.Layer.TileCellsX)
                        {
                            System.Drawing.Point p = new System.Drawing.Point((x * LayerEditor.Layer.Definition.Grid.Width) + LayerEditor.Layer.Definition.Grid.Width, (y * LayerEditor.Layer.Definition.Grid.Height));
                            SetCaveTile(p, (int)FlxCaveGenerator.random(LayerEditor.Layer.Tileset.TilesAcross * 3, LayerEditor.Layer.Tileset.TilesAcross * 4));
                        }
                    }


                    //
                }
            }

            for (int y = 0; y < sizeY; y++)
            {
                for (int x = 0; x < sizeX; x++)
                {
                    if ((LayerEditor.Layer.Tiles[x, y] == 6) && x >= 1)
                    {
                        System.Drawing.Point p = new System.Drawing.Point((x * LayerEditor.Layer.Definition.Grid.Width) - LayerEditor.Layer.Definition.Grid.Width, (y * LayerEditor.Layer.Definition.Grid.Height));
                        SetCaveTile(p, (int)FlxCaveGenerator.random(LayerEditor.Layer.Tileset.TilesAcross * 4, LayerEditor.Layer.Tileset.TilesAcross * 5));
                    }


                    if ((LayerEditor.Layer.Tiles[x, y] == 12) && y < LayerEditor.Layer.TileCellsX)
                    {
                        System.Drawing.Point p = new System.Drawing.Point((x * LayerEditor.Layer.Definition.Grid.Width) + LayerEditor.Layer.Definition.Grid.Width, (y * LayerEditor.Layer.Definition.Grid.Height));
                        SetCaveTile(p, (int)FlxCaveGenerator.random(LayerEditor.Layer.Tileset.TilesAcross * 3, LayerEditor.Layer.Tileset.TilesAcross * 4));
                    }
                }
            }
        }
Пример #8
0
        public void cave(int custom = 0)
        {
            int sizeX = LayerEditor.Layer.TileCellsX;
            int sizeY = LayerEditor.Layer.TileCellsY;

            Console.WriteLine("Size X {0} Size Y {1} - crashes? ", sizeX, sizeY);


            FlxCaveGenerator cave = new FlxCaveGenerator(sizeX, sizeY);

            cave.genInitMatrix(sizeX, sizeY);
            int[,] level = cave.generateCaveLevel();

            for (int y = 0; y < sizeY; y++)
            {
                for (int x = 0; x < sizeX; x++)
                {
                    if (LayerEditor.Layer.Tiles[x, y] == -1)
                    {
                        level[y, x] = 0;
                    }
                    else if (LayerEditor.Layer.Tiles[x, y] <= LayerEditor.Layer.Tileset.TilesAcross - 1)
                    {
                        level[y, x] = 1;
                    }
                    // HACK : Setting this decoration tile to a negative number so doesn't affect auto-tiling
                    // HACK : Revert to original before setting tile.
                    else
                    {
                        level[y, x] = (LayerEditor.Layer.Tiles[x, y] + 1) * -1;
                    }
                }
            }

            //level = cave.smoothLevel(level);

            string MapData = cave.convertMultiArrayToString(level);

            int heightInTiles = 0;

            //Figure out the map dimensions based on the data string
            string[] cols;
            string[] rows = MapData.Split('\n');
            heightInTiles = rows.Length;
            int r = 0;
            int c;

            cols  = rows[r].Split(',');
            _data = new int[rows.Length * cols.Length];
            while (r < heightInTiles)
            {
                cols = rows[r++].Split(',');
                if (cols.Length <= 1)
                {
                    heightInTiles = heightInTiles - 1;
                    continue;
                }
                if (widthInTiles == 0)
                {
                    widthInTiles = cols.Length;
                }
                c = 0;

                // TODO:
                // This causes a crash in some situations. //

                while (c < widthInTiles)
                {
                    _data[((r - 1) * widthInTiles) + c] = int.Parse(cols[c++]);
                }
            }

            int total      = 0;
            int ii         = 0;
            int totalTiles = LayerEditor.Layer.TileCellsX * LayerEditor.Layer.TileCellsY;

            while (ii < totalTiles)
            {
                if (custom == 1)
                {
                    customAutoTile(ii++);
                }
                else if (custom == 2)
                {
                    squareAutoTile(ii++);
                }
                else
                {
                    autoTile(ii++);
                }
            }

            total = 0;

            for (int y = 0; y < sizeY; y++)
            {
                for (int x = 0; x < sizeX; x++)
                {
                    System.Drawing.Point p = new System.Drawing.Point(x * LayerEditor.Layer.Definition.Grid.Width, y * LayerEditor.Layer.Definition.Grid.Height);

                    SetCaveTile(p, -1);

                    if (_data[total] >= 1)
                    {
                        SetCaveTile(p, _data[total] - 1);
                    }
                    else if (_data[total] == 0)
                    {
                        SetCaveTile(p, -1);
                    }
                    // HACK : Since this is a negative number, it's a decoration tile.
                    // HACK : Reverse the tile number to revert back to decoration.
                    else if (_data[total] < 0)
                    {
                        SetCaveTile(p, (_data[total] + 1) * -1);
                    }
                    total++;
                }
            }
        }
Пример #9
0
        public void customAutoTile(int Index)
        {
            int totalTiles = LayerEditor.Layer.TileCellsX * LayerEditor.Layer.TileCellsY;

            if (_data[Index] == 0)
            {
                return;
            }
            _data[Index] = 0;
            if ((Index - widthInTiles < 0) || (_data[Index - widthInTiles] > 0))                //UP
            {
                _data[Index] += 1;
            }
            if ((Index % widthInTiles >= widthInTiles - 1) || (_data[Index + 1] > 0))           //RIGHT
            {
                _data[Index] += 2;
            }
            if ((Index + widthInTiles >= totalTiles) || (_data[Index + widthInTiles] > 0)) //DOWN
            {
                _data[Index] += 4;
            }
            if ((Index % widthInTiles <= 0) || (_data[Index - 1] > 0))                                  //LEFT
            {
                _data[Index] += 8;
            }

            if ((auto == ALT) && (_data[Index] == 15))  //The alternate algo checks for interior corners
            {
                if ((Index % widthInTiles > 0) && (Index + widthInTiles < totalTiles) && (_data[Index + widthInTiles - 1] <= 0))
                {
                    _data[Index] = 1;           //BOTTOM LEFT OPEN
                }
                if ((Index % widthInTiles > 0) && (Index - widthInTiles >= 0) && (_data[Index - widthInTiles - 1] <= 0))
                {
                    _data[Index] = 2;           //TOP LEFT OPEN
                }
                if ((Index % widthInTiles < widthInTiles - 1) && (Index - widthInTiles >= 0) && (_data[Index - widthInTiles + 1] <= 0))
                {
                    _data[Index] = 4;           //TOP RIGHT OPEN
                }
                if ((Index % widthInTiles < widthInTiles - 1) && (Index + widthInTiles < totalTiles) && (_data[Index + widthInTiles + 1] <= 0))
                {
                    _data[Index] = 8;           //BOTTOM RIGHT OPEN
                }
            }

            _data[Index] += 1;

            //extra part for if you have extra tiles.

            _extraMiddleTiles = LayerEditor.Layer.Tileset.TilesAcross;

            if (_extraMiddleTiles >= 16 && _data[Index] == 16)
            {
                _data[Index] += ((int)(FlxCaveGenerator.random(16, _extraMiddleTiles + 1)) - 16);
            }

            //remap to custom
            if (auto != ALT)
            {
                if (_data[Index] == 1)
                {
                    _data[Index] = 4;
                }                                                       // FIX
                else if (_data[Index] == 2)
                {
                    _data[Index] = 4;
                }                                                       // FIX
                else if (_data[Index] == 3)
                {
                    _data[Index] = 5;
                }                                                       // FIX
                else if (_data[Index] == 4)
                {
                    _data[Index] = 129;
                }                                                       // |_
                else if (_data[Index] == 5)
                {
                    _data[Index] = 4;
                }                                                       // FIX
                else if (_data[Index] == 6)
                {
                    _data[Index] = 5;
                }                                                       // FIX
                else if (_data[Index] == 7)
                {
                    _data[Index] = 9;
                }                                                       // |^
                else if (_data[Index] == 8)
                {
                    _data[Index] = 29;
                }                                                       // |=
                else if (_data[Index] == 9)
                {
                    _data[Index] = 4;
                }                                                       // FIX
                else if (_data[Index] == 10)
                {
                    _data[Index] = 135;
                }                                                       // _|
                else if (_data[Index] == 11)
                {
                    _data[Index] = 5;
                }                                                       // FIX
                else if (_data[Index] == 12)
                {
                    _data[Index] = 130;
                }                                                       // _
                else if (_data[Index] == 13)
                {
                    _data[Index] = 15;
                }                                                       // ^|
                else if (_data[Index] == 14)
                {
                    _data[Index] = 35;
                }                                                       // =|
                else if (_data[Index] == 15)
                {
                    _data[Index] = 10;
                }                                                       // ^
                else if (_data[Index] >= 16)
                {
                    _data[Index] = 195;
                }                                                       // Empty
            }
            else // is ALT
            {
                if (_data[Index] == 1)
                {
                    _data[Index] = 4;
                }                                                       // FIX
                else if (_data[Index] == 2)
                {
                    _data[Index] = 17;
                }                                                       //      //BOTTOM LEFT OPEN
                else if (_data[Index] == 3)
                {
                    _data[Index] = 37;
                }                                                       //      //TOP LEFT OPEN
                else if (_data[Index] == 4)
                {
                    _data[Index] = 129;
                }                                                       // |_
                else if (_data[Index] == 5)
                {
                    _data[Index] = 36;
                }                                                       //      //TOP RIGHT OPEN
                else if (_data[Index] == 6)
                {
                    _data[Index] = 5;
                }                                                       // FIX
                else if (_data[Index] == 7)
                {
                    _data[Index] = 9;
                }                                                       // |^
                else if (_data[Index] == 8)
                {
                    _data[Index] = 29;
                }                                                       // |=
                else if (_data[Index] == 9)
                {
                    _data[Index] = 16;
                }                                                       //      //BOTTOM RIGHT OPEN
                else if (_data[Index] == 10)
                {
                    _data[Index] = 135;
                }                                                       // _|
                else if (_data[Index] == 11)
                {
                    _data[Index] = 5;
                }                                                       // FIX
                else if (_data[Index] == 12)
                {
                    _data[Index] = 130;
                }                                                       // _
                else if (_data[Index] == 13)
                {
                    _data[Index] = 15;
                }                                                       // ^|
                else if (_data[Index] == 14)
                {
                    _data[Index] = 35;
                }                                                       // =|
                else if (_data[Index] == 15)
                {
                    _data[Index] = 10;
                }                                                       // ^
                else if (_data[Index] >= 16)
                {
                    _data[Index] = 195;
                }                                                       // Empty
            }
        }
Пример #10
0
        public void cave()
        {
            int sizeX = LayerEditor.Layer.TileCellsX;
            int sizeY = LayerEditor.Layer.TileCellsY;

            FlxCaveGenerator cave = new FlxCaveGenerator(sizeX, sizeY);

            cave.genInitMatrix(sizeX, sizeY);
            int[,] level = cave.generateCaveLevel();

            for (int y = 0; y < sizeY; y++)
            {
                for (int x = 0; x < sizeX; x++)
                {
                    if (LayerEditor.Layer.Tiles[x, y] == -1)
                    {
                        level[y, x] = 0;
                    }
                    else
                    {
                        level[y, x] = 1;
                    }
                }
            }

            level = cave.smoothLevel(level);

            string MapData = cave.convertMultiArrayToString(level);

            int heightInTiles = 0;

            //Figure out the map dimensions based on the data string
            string[] cols;
            string[] rows = MapData.Split('\n');
            heightInTiles = rows.Length;
            int r = 0;
            int c;

            cols  = rows[r].Split(',');
            _data = new int[rows.Length * cols.Length];
            while (r < heightInTiles)
            {
                cols = rows[r++].Split(',');
                if (cols.Length <= 1)
                {
                    heightInTiles = heightInTiles - 1;
                    continue;
                }
                if (widthInTiles == 0)
                {
                    widthInTiles = cols.Length;
                }
                c = 0;
                while (c < widthInTiles)
                {
                    _data[((r - 1) * widthInTiles) + c] = int.Parse(cols[c++]);
                }
            }

            int total      = 0;
            int ii         = 0;
            int totalTiles = LayerEditor.Layer.TileCellsX * LayerEditor.Layer.TileCellsY;

            while (ii < totalTiles)
            {
                autoTile(ii++);
            }

            total = 0;

            for (int y = 0; y < sizeY; y++)
            {
                for (int x = 0; x < sizeX; x++)
                {
                    System.Drawing.Point p = new System.Drawing.Point(x * LayerEditor.Layer.Definition.Grid.Width, y * LayerEditor.Layer.Definition.Grid.Height);

                    SetCaveTile(p, -1);

                    if (_data[total] >= 1)
                    {
                        SetCaveTile(p, _data[total] - 1);
                    }
                    else
                    {
                        SetCaveTile(p, -1);
                    }
                    total++;
                }
            }
        }