Ejemplo n.º 1
0
 public static void unloadWithoutRemoval(Texture2D tex)
 {
     for (int index = 0; index < TextureBank.textures.Count; ++index)
     {
         if (TextureBank.textures[index].tex.Equals((object)tex))
         {
             if (TextureBank.textures[index].tex.IsDisposed)
             {
                 TextureBank.textures.Remove(TextureBank.textures[index]);
             }
             else
             {
                 LoadedTexture texture = TextureBank.textures[index];
                 --texture.retainCount;
                 TextureBank.textures[index] = texture;
                 break;
             }
         }
     }
 }
Ejemplo n.º 2
0
 public static Texture2D load(string filename, ContentManager content)
 {
     for (int index = 0; index < TextureBank.textures.Count; ++index)
     {
         if (TextureBank.textures[index].path.Equals(filename))
         {
             if (TextureBank.textures[index].tex.IsDisposed)
             {
                 TextureBank.textures.Remove(TextureBank.textures[index]);
             }
             else
             {
                 LoadedTexture texture = TextureBank.textures[index];
                 ++texture.retainCount;
                 TextureBank.textures[index] = texture;
                 return(texture.tex);
             }
         }
     }
     try
     {
         Texture2D texture2D = content.Load <Texture2D>(filename);
         TextureBank.textures.Add(new LoadedTexture()
         {
             tex         = texture2D,
             path        = filename,
             retainCount = 1
         });
         return(texture2D);
     }
     catch (Exception ex)
     {
         Console.WriteLine("File \"" + filename + "\" Experienced an Error in Loading\n" + (object)ex);
         return((Texture2D)null);
     }
 }