Ejemplo n.º 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;

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