Exemplo n.º 1
0
 public TexturePack(int imageNumber, string textureName, Texture2D texture2D)
 {
     nextTexturePack  = null;
     this.imageNumber = imageNumber;
     this.texture2D   = texture2D;
     this.textureName = textureName;
 }
Exemplo n.º 2
0
        static public int AddImage(string imageName, string imagePathAndFileName)
        {
            TexturePack stepPack = firstTexturePack;

            if (firstTexturePack != null)
            {
                // Find last texturepack
                while (stepPack.nextTexturePack != null)
                {
                    if (stepPack.textureName == imageName)
                    {
                        return(stepPack.imageNumber);
                    }
                    stepPack = stepPack.nextTexturePack;
                }

                TexturePack newImage = new TexturePack(uniqueTextureId, imageName,
                                                       Texture2D.FromStream(graphicsDevice,
                                                                            File.OpenRead(imagePathAndFileName)));

                uniqueTextureId++;
                stepPack.nextTexturePack = newImage;
            }
            else
            {
                TexturePack newImage = new TexturePack(uniqueTextureId, imageName,
                                                       Texture2D.FromStream(graphicsDevice,
                                                                            File.OpenRead(imagePathAndFileName)));

                uniqueTextureId++;
                firstTexturePack = newImage;
            }

            return(uniqueTextureId);
        }
Exemplo n.º 3
0
        static public Texture2D GetImageWithId(int imageId)
        {
            TexturePack stepTexture = firstTexturePack;

            while (stepTexture != null)
            {
                if (stepTexture.imageNumber == imageId)
                {
                    return(stepTexture.texture2D);
                }

                stepTexture = stepTexture.nextTexturePack;
            }

            return(null);
        }
Exemplo n.º 4
0
 static public void ClearAllImages()
 {
     firstTexturePack = null;
     GC.Collect();
 }
Exemplo n.º 5
0
 static public void Initialize(GraphicsDevice currentGraphicsDevice)
 {
     firstTexturePack = null;
     graphicsDevice   = currentGraphicsDevice;
     uniqueTextureId  = 0;
 }