Exemple #1
0
 public GameTexture(string p_filename, Size p_cellSize, TextureDisposePolicy p_textureDisposePolicy)
 {
     this.colorswap = -1;
     this.disposePolicy = p_textureDisposePolicy;
     this.filename = p_filename;
     this.cellSize = p_cellSize;
     Bitmap bitmap = new Bitmap(GameEngine.Framework.GetResourceStream("Images." + this.filename.ToLower()));
     this.xCells = bitmap.Width / this.cellSize.Width;
     this.yCells = bitmap.Height / this.cellSize.Height;
     this.textureSize = new Size(bitmap.Width, bitmap.Height);
     this.animatedTiles = new Point[0];
 }
Exemple #2
0
 private void DisposeTextures(TextureDisposePolicy disposeType)
 {
     foreach (string str in this.textureDisposePolicies.Keys)
     {
         if (((TextureDisposePolicy) this.textureDisposePolicies[str]) >= disposeType)
         {
             this.textureCollection.Remove(str);
         }
     }
 }
Exemple #3
0
 public Texture GetTexture(string fileName, int initialColor, int colorSwap, Size size, TextureDisposePolicy disposePolicy)
 {
     Texture texture;
     if (!this.devicePresent)
     {
         return null;
     }
     string key = fileName + "|" + colorSwap.ToString();
     if (!this.textureCollection.TryGetValue(key, out texture))
     {
         int colorKey = new ColorValue(0xff, 0x94, 0xff, 0xff).ToArgb();
         texture = TextureLoader.FromStream(this.renderDevice, this.GetResourceStream("Images." + fileName.ToLower()), 0, 0, 1, Usage.None, Format.A8R8G8B8, Pool.Managed, Filter.None, Filter.None, colorKey);
         if (initialColor != -1)
         {
             GameTexture.SwapColors(texture, size, initialColor, colorSwap, false);
         }
         this.textureCollection.Add(key, texture);
         if (this.textureDisposePolicies.ContainsKey(key))
         {
             this.textureDisposePolicies.Remove(key);
         }
         this.textureDisposePolicies.Add(key, disposePolicy);
     }
     return texture;
 }