예제 #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 create()
        {
            ImgTiles = FlxG.Content.Load<Texture2D>("Mode/tiles_all");

            //load map from file
            string sMap;
            using (Stream file = TitleContainer.OpenStream("Content/" + TxtMap))
            {
                StreamReader sr = new StreamReader(file);
                sMap = sr.ReadToEnd().Replace("\r", "");
                sr.Close();
            }
            //create tilemap
            _tilemap = new FlxTilemap();
            _tilemap.collideIndex = 3;
            _tilemap.loadMap(sMap, ImgTiles, 8, 8);
            //_tilemap.loadMap(new TxtMap2,ImgTiles,8); //This is an alternate tiny map

            //create player and bullets
            _bullets = new FlxGroup();
            _player = new Player((int)(_tilemap.width/2-4),(int)_tilemap.height/2-4,_bullets.members,null);
            for(int i = 0; i < 8; i++)
                _bullets.add(new Bullet());
            add(_bullets);

            //add player and set up camera
            add(_player);
            FlxG.follow(_player,2.5f);
            FlxG.followAdjust(0.5f,0.0f);
            _tilemap.follow();	//Set the followBounds to the map dimensions

            //Uncomment these lines if you want to center TxtMap2
            //var fx:uint = _tilemap.width/2 - FlxG.width/2;
            //var fy:uint = _tilemap.height/2 - FlxG.height/2;
            //FlxG.followBounds(fx,fy,fx,fy);

            //add tilemap last so it is in front, looks neat
            add(_tilemap);

            //fade in
            FlxG.flash.start(new Color(0x13, 0x1c, 0x1b), 1f);

            //The music in this mode is positional - it fades out toward the edges of the level
            FlxSound s = FlxG.play(SndMode,1,true);
            s.proximity(320,320,_player,160);
        }
예제 #3
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);
                }
            }
        }
예제 #4
0
        private void buildCave2()
        {
            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);
        }