public ResourceManager() { _imageFolder = Path.Combine(Path.GetDirectoryName( Application.ExecutablePath), @"Resources\Image"); _audioFolder = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), @"Resources\Audio"); string[] imageLocations = Directory.GetFiles(_imageFolder); _textures = new ImageTexture[imageLocations.Length]; for(int i=0;i<imageLocations.Length;i++){ string imageLocation = imageLocations[i]; try { Bitmap bitmap = new Bitmap(imageLocation); string name = Path.GetFileNameWithoutExtension(imageLocation); var texture = new ImageTexture(bitmap, name); _textures[i] = texture; } catch(Exception err){ System.Console.Out.WriteLine(err.Message); } } string[] audioLocations = Directory.GetFiles(_audioFolder); _sounds = new AudioLocation[audioLocations.Length]; for(int i=0;i<audioLocations.Length;i++){ string location = audioLocations[i]; string name = Path.GetFileNameWithoutExtension(location); AudioLocation sound = new AudioLocation(); sound.Name = name; sound.Location = location; _sounds[i] = sound; } }
public ResourceManager() { _imageFolder = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), @"Resources\Image"); _audioFolder = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), @"Resources\Audio"); string[] imageLocations = Directory.GetFiles(_imageFolder); _textures = new ImageTexture[imageLocations.Length]; for (int i = 0; i < imageLocations.Length; i++) { string imageLocation = imageLocations[i]; try { Bitmap bitmap = new Bitmap(imageLocation); string name = Path.GetFileNameWithoutExtension(imageLocation); var texture = new ImageTexture(bitmap, name); _textures[i] = texture; } catch (Exception err) { System.Console.Out.WriteLine(err.Message); } } string[] audioLocations = Directory.GetFiles(_audioFolder); _sounds = new AudioLocation[audioLocations.Length]; for (int i = 0; i < audioLocations.Length; i++) { string location = audioLocations[i]; string name = Path.GetFileNameWithoutExtension(location); AudioLocation sound = new AudioLocation(); sound.Name = name; sound.Location = location; _sounds[i] = sound; } }