Esempio n. 1
0
        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;
     }
 }
Esempio n. 3
0
 public void SetTexture(ImageTexture texture)
 {
     if (texture != null)
     {
         _texture = texture;
     }
 }
Esempio n. 4
0
        public void SetTexture(string name)
        {
            var t = ResourceManager.GetTexture(name);

            if (t != null)
            {
                _texture = t;
            }
        }
Esempio n. 5
0
 public void SetTexture(ImageTexture texture)
 {
     if(texture != null){
         _texture = texture;
     }
 }
Esempio n. 6
0
 public void SetTexture(string name)
 {
     var t = ResourceManager.GetTexture(name);
     if(t != null){
         _texture = t;
     }
 }