Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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));
                    }
                }
            }
        }
Ejemplo n.º 3
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
            }
        }