Ejemplo n.º 1
0
        public RoomData[,] GenerateMap(MapGenerationSettings mapGenSettings)
        {
            this.mapGenSettings = mapGenSettings;

            loadRoomTemplates();

            rooms = rooms = new RoomData[mapGenSettings.NumRoomsX, mapGenSettings.NumRoomsY];

            generateRooms();

            Resources.UnloadUnusedAssets();

            return(rooms);
        }
Ejemplo n.º 2
0
        private static List <RoomTemplate> loadRoomTemplateCategory(string directory, MapGenerationSettings mapGenSettings)
        {
            var templates = new List <RoomTemplate>();

            // Load room templates.
            string templatePath = Path.Combine(mapGenSettings.TemplatesRootDir, directory);

            Texture2D[] templateTextures = Resources.LoadAll(templatePath, typeof(Texture2D)).Cast <Texture2D>().ToArray();

            Debug.Log(templatePath);

            foreach (Texture2D templateTexture in templateTextures)
            {
                // Create template for this room;
                var template = new RoomTemplate(mapGenSettings.RoomWidth, mapGenSettings.RoomHeight);

                Color[] pixels = templateTexture.GetPixels();

                for (int ix = 0; ix < mapGenSettings.RoomWidth; ix++)
                {
                    for (int iy = 0; iy < mapGenSettings.RoomHeight; iy++)
                    {
                        Color pixel = pixels[iy * mapGenSettings.RoomWidth + ix];
                        template.Tiles[ix, iy] = pixel == Color.white;
                    }
                }

                templates.Add(template);
            }

            return(templates);
        }
Ejemplo n.º 3
0
 public static List <RoomTemplate> LoadRoomsOpenBottom(MapGenerationSettings mapGenSettings)
 {
     return(loadRoomTemplateCategory(templateDirectoryOpenBottom, mapGenSettings));
 }