Esempio n. 1
0
        private void SetupTemplatedMap()
        {
            var w         = 70;
            var h         = 70;
            var ts        = 32;
            var templates = LoadRoomTemplatesFromFile(Path.Combine(content.RootDirectory, "Templates.txt"));

            //tData = string.Empty;
            //tData += "........................";
            //tData += "........................";
            //tData += "........................";
            //tData += "........xxxxxxxx........";
            //tData += "........xxxxxxxx........";
            //tData += "........xxxxxxxx........";
            //templates.Add(new RoomTemplate(24, 6, tData, "tooth"));

            var gen = new TemplatedMapGenerator()
            {
                DesiredRoomCount = 40
            };

            gen.AddTemplates(templates.ToArray());

            var map = gen.CreateMap(w, h);

            var custMap = new CustomTiledMap(0, map.Width, map.Height, ts, ts);
            var tileset = new TiledTileset(_texture, -1, ts, ts, 0, 0, 4, 4);

            custMap.loadFromArray("basic", map.GetMap().Select(x => (int)x).ToArray(), map.Width, map.Height, tileset, ts, ts);


            var mapEntity = createEntity("tiled-map");

            mapEntity.addComponent(new TiledMapComponent(custMap, shouldCreateColliders: false));
        }
Esempio n. 2
0
        private void SetupBspMap()
        {
            var w  = 70;
            var h  = 70;
            var ts = 32;

            var gen = new MessyBSPTreeMapGenerator(w, h);
            var map = gen.CreateMap();

            Debug.log(map.ToString());

            var custMap = new CustomTiledMap(0, map.Width, map.Height, ts, ts);
            var tileset = new TiledTileset(_texture, 0, ts, ts, 0, 0, 4, 4);

            custMap.loadFromArray("basic", map.GetMap().Select(x => (int)x).ToArray(), map.Width, map.Height, tileset, ts, ts);

            var mapEntity = createEntity("tiled-map");

            mapEntity.addComponent(new TiledMapComponent(custMap, shouldCreateColliders: false));
        }