private static List <Sprite> LoadSprites(string path) { var dictionaryInfoHelper = new DictionaryInfoHelper(); var sprites = new List <Sprite>(); var spritesNames = dictionaryInfoHelper .GetFilesNames(path) .Where(name => name.EndsWith(".png")).ToList(); foreach (var spriteName in spritesNames) { sprites.Add(AssetDatabase.LoadAssetAtPath <Sprite>(path + "/" + spriteName)); } return(sprites); }
public static void GeneratePrefabs() { var dictionaryInfoHelper = new DictionaryInfoHelper(); const string spritesFolderPath = "Assets/Entities/BoardGenerators/Dungeon/Sprites/"; const string prefabsFolderPath = "Assets/Resources/Board/Dungeon/"; foreach (var folderName in dictionaryInfoHelper.GetFolderNames(spritesFolderPath)) { var spritesPath = spritesFolderPath + folderName; var prefabsPath = prefabsFolderPath + folderName; if (!Directory.Exists(prefabsPath)) { Directory.CreateDirectory(prefabsPath); } var sprites = LoadSprites(spritesPath); CreatePrefabs(prefabsPath, sprites); } }
private void Initialize() { Board = new BoardInfo() { BoardFields = new BoardField[BoardWidth, BoardHeight], BoardObstacles = new FiledStatus[BoardWidth, BoardHeight] }; _dictionaryInfoHelper = new DictionaryInfoHelper(); _outerFloorTilesPostitions = new List <Vector2>(); _innerFloorTilesPostitions = new List <Vector2>(); _filedsByType = new Dictionary <BoardField, List <GameObject> >(); _fieldTypeByNeigbors = new Dictionary <string, BoardField> { // 1 { "1000", BoardField.TopWall }, { "0100", BoardField.RightWall }, { "0010", BoardField.BottomWall }, { "0001", BoardField.LeftWall }, // 2 { "1100", BoardField.TopRightWall }, { "1010", BoardField.TopBottomWall }, { "1001", BoardField.TopLeftWall }, { "0110", BoardField.RightBottomWall }, { "0101", BoardField.RightLeftWall }, { "0011", BoardField.BottomLeftWall }, // 3 { "1110", BoardField.TopRightBottomWall }, { "1101", BoardField.TopRightLeftWall }, { "1011", BoardField.TopBottomLeftWall }, { "0111", BoardField.RightBottomLeftWall }, // 4 { "1111", BoardField.FullWall } }; }